I found an MSDN article that describes how EF handles concurrency when saving changes:
By default [...] Object Services saves object changes to the database without checking for concurrency. For properties that might experience a high degree of concurrency, we recommend that the entity property be defined in the conceptual layer with an attribute of ConcurrencyMode="fixed"
I have two questions:
Having no properties in my model where
ConcurrencyMode="fixed"
, is it safe for me to assume that if ever anOptimisticConcurrencyException
is thrown when saving changes, it is because the entity no longer exists in the data store, i.e. it has been deleted by another user, or am I missing something?I imagine EF executing an
UPDATE
-statement that looks something like this, which, as I see it, will only cause anOptimisticConcurrencyException
to be thrown if the Person with ID = 1 doesn't exist:UPDATE Person SET FirstName = 'John' AND LastName = 'Smith' WHERE ID = 1
When using
ConcurrencyMode="fixed"
, does EF check for concurrency when deleting entities as well? In other words, will EF ever execute aDELETE
-statement that looks like this (with more than just the primary key in theWHERE
-clause):DELETE FROM Person WHERE ID = 1 AND LastName = 'Doe'