Database concurrency
A concurrency conflict occurs when multiple users try to change the same data simultaneously. For example, if user one and user two load the same product from database, the user who clicks submit button last will be the one who wins, and the user's data will override the first user's data without any warning being given to either user.
How to handle the concurrency problem?
A. Pessimistic concurrency. This approach uses the database row lock. Obviously, this approach has performance problem.
B. Optimistic concurrency. This approach verifies that the data to be updated has not been modified after retrieving. Entity framework supports this approach.
With entity framework, you need to define a timestamp column in the database table, then you need to put a [Timestamp] attribute for the column in the entity model. Then when you try to update a table, entity framework will check if the data has been changed by comparing the time stamp filed, if it has been changed , then entity framework will throw a exception of OptimisticConcurrencyException.
But Timestamp data type of SQL Server will be removed in the future, one new equivalent data type rowversion should be used.