If I set a property of an entity Album, let’s say Album.Name = "Greatest Hits", but Album.Name == "Greatest Hits" was true before, DbContext.Entry<Album>(Album).State is set to EntityState.Modified. This seems to be wrong, because there is no change.
If I call DbContext.SaveChanges() later, I get an odd DbUpdateConcurrencyException. If you catch this exception, you can compare database values and local values (see https://docs.microsoft.com/en-us/ef/ef6 ... oncurrency). But these values do not differ!
This seems to be a bug. I can try to create a minimal working example if needed.
Entry state modified even if no property was modified (DbUpdateConcurrencyException)
Re: Entry state modified even if no property was modified (DbUpdateConcurrencyException)
The issue is caused by change tracking implementation in EF engine. Refer to https://stackoverflow.com/questions/135 ... -is-set-b/.
Re: Entry state modified even if no property was modified (DbUpdateConcurrencyException)
Thank you. That’s strange …
If I set FoundRows = true in a MySqlConnectionStringBuilder instance, I don’t get the exception. Is setting FoundRows the right way / best practice?
If I set FoundRows = true in a MySqlConnectionStringBuilder instance, I don’t get the exception. Is setting FoundRows the right way / best practice?
Re: Entry state modified even if no property was modified (DbUpdateConcurrencyException)
"FoundRows=true;" in the connection string is the right way.
FoundRows specifies whether the provider will return the number of rows matched by the WHERE condition of the UPDATE statement instead of the rows actually changed as the number of changed rows.
FoundRows specifies whether the provider will return the number of rows matched by the WHERE condition of the UPDATE statement instead of the rows actually changed as the number of changed rows.