You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When saving changes, EFCore only checks the concurrency token of a row when the entity is modified. Consider the folowing situation:
First I fetch record p. I'm not going to modify record p, but I want to ensure record p is unchanged until savechanges(). (like a SHARE lock)
solution
Force efcore to check the ConcurrencyToken of an entity. Maybe by executing SELECT 1 FROM students WHERE student_id=11 AND concurrency_token=55 FOR SHARE and throw exception if null is returned.
The text was updated successfully, but these errors were encountered:
Note from triage: Putting on the backlog to consider.
@crclz The only workaround I can come up with at the moment is to mark either the entire entity or some property as modified even when it isn't. This isn't great of course, because it will cause updates when they aren't needed.
@ajcvickers Yes, marking the whole or a part of the entity is not a good solution. Not only because it does unneeded updates, but also because it uses EXCLUSIVE lock when SHARE lock is ok, which increase the possibility of transaction failure (concurrency violation) and decreases throughput.
Additionally, some feature of efcore make it quite fit for DDD(Domain Driven Design), but now it seems there is not an eazy way for EFCore to guarantee the consistency within an aggregate root.
problem
When saving changes, EFCore only checks the concurrency token of a row when the entity is modified. Consider the folowing situation:
First I fetch record p. I'm not going to modify record p, but I want to ensure record p is unchanged until savechanges(). (like a SHARE lock)
solution
Force efcore to check the ConcurrencyToken of an entity. Maybe by executing
SELECT 1 FROM students WHERE student_id=11 AND concurrency_token=55 FOR SHARE
and throw exception if null is returned.The text was updated successfully, but these errors were encountered: