This Microsoft blog post contains links to a number of EF6 and MVC guides. There is one in particular you should check out - Handling Concurrency with the Entity Framework 6. The guide is using an ASP.Net MVC project, but the database principles should apply to almost any type of project.
In short, though, if you use a ConcurrencyCheck
attribute then you don't have to update any counter yourself - but it adds more overhead to your application's database operations because under the hood EF will be extrapolating every SQL query to include concurrency checks for properties that you have applied the ConcurrencyCheck
attribute to. If you have a very large table (lots of columns), this can cause slower application performance.
The better way would be for you to use TimeStamp
attribute on a byte array property in your code-first class (or if you are using Fluent API you set IsConcurrencyToken()
on the property). Then, if there is a concurrency conflict EF will throw a DbUpdateConcurrencyException
- it's up to you to then catch it and handle it accordingly.