tags:

views:

31

answers:

1

Hello How can I change EntityState from NotTracked to Modified of my CurrentEntity. I mean I do modify my CurrentyEntity but the EntityState shows NotTracked where it should be Modified. What could be reason behind this..?

A: 

If you make a change to a disconnected entity and want it to be change tracked, you can use the .Attach(..) method on your datacontext, ie:

context.Products.Attach(product, true);

You can read more about Linq to Sql and disconnected entities on MSDN:

Data Retrieval and CRUD Operations in N-Tier Applications (LINQ to SQL)

James H