During the
_dbContext.Update(entity)
The following exceptions occurs:
System.InvalidOperationException: 'Unable to track an entity of type 'User' because alternate key property 'id' is null. If the alternate key is not used in a relationship, then consider using a unique index instead. Unique indexes may contain nulls, while alternate keys must not.'
Looking into the way I've configured the DbContext:
modelBuilder.Entity<User>().HasKey(p => p.Id);
Running the following sql command in cosmos emulator, returns the correct entity:
SELECT * FROM c where c.Id="My-Guid-Id"
How can I update an existing entity using Entity Framework as ORM and Cosmos as my database provider?
id
. Please read How to Ask and provide all relevant details.User
class and all related calls tomodelBuilder
that somehow referenceUser
and its, again, lowercaseid
property that your error message mentions. Don't just change your code and error message before posting a question, because that might drastically change the actual cause.