How to leverage concurrency checking with EF 4.0 POCO Self Tracking Entities in a N-Tier scenario?

Posted by Mark Lindell on Stack Overflow See other posts from Stack Overflow or by Mark Lindell
Published on 2010-03-05T16:38:14Z Indexed on 2010/05/07 12:58 UTC
Read the original article Hit count: 417

I'm using VS1010RC with the POCO self tracking T4 templates.

In my WCF update service method I am using something similar to the following:

using (var context = new MyContext())
{
  context.MyObjects.ApplyChanges(myObject);
  context.SaveChanges();
}

This works fine until I set ConcurrencyMode=Fixed on the entity and then I get an exception. It appears as if the context does not know about the previous values as the SQL statement is using the changed entities value in the WHERE clause.

What is the correct approach when using ConcurrencyMode=Fixed?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about POCO