First you need to determine which property or properties will be used to perform the concurrency check, because concurrency is defined in properties by the properties in the Entity Framework. ConcurrencyMode is used to mark the properties for checking concurrency and can be found in the properties window of the Entity object (just right-click the Person object in your model). Its options are None , which is the default, and Fixed .
During a SaveChanges call, if the field has been changed in the database since the row was restored, EF will cancel the save and throw an OptimisticConcurrencyException if we set this ConcurrencyMode field to Fixed.
Under the hood, EF includes this field value in the SQL update or delete statement, which is passed to the data store as a WHERE clause.
If you want to have Optimistic concurrency for all properties, just set the TimeStamp ConcurrencyMode property to Fixed, you will get an OptimisticConcurrencyException if any field value in the table changes (instead of setting it to Fixed in each property).
EDIT
According to Craig's comment below, you need to save the TimeStamp in the view and read it back into the Person object, and EF will take care of the rest if you set the ConcurrencyMode parameter to the TimeStamp property. You can, of course, try to handle the OptimisticConcurrencyException that EF can throw, and there are ways to throw this exception if you are interested.
Morteza manavi
source share