My project uses EF (tested with version 4 using self-tracking template and with version 5 using default templates, all database-first) against SQL Server 2012. The database tables have each a rowversion
(timestamp
) column defined.
Using EF in it core, meaning my code on database updates looking so:
using (var db = new MyContext())
{
//db.Entry(myInstance).State = EntityState.Modified;
db.SaveChanges();
}
does not trigger any rowversion
alerts. I run parallel clients, each reads the same record, makes a change to it and then each writes it to the database. All updates are accepted, no concurrency is applied.
Do I have to work with stored procedures for my update commands (with a where clause that states my rowversion
value) to have EF acknowledge the "built-in" concurrency or is there another way (configuration, specific method calls) to make my code work?