Question

I have an object which is added to an objectContext ..

after some operation i need to pass it to another objectcontext of the same database but i always face this message :


An entity object cannot be referenced by multiple instances of IEntityChangeTracker.


i need to change tracking information be detach it from the old object and attach it to the new objectcontext..

but in the new scope i doesn't own the old objectContext to detach it before

My question : How to change Tracking information of this object to the new ObjectContext?

Was it helpful?

Solution

You must Detach the entity from the first context while that context is still in scope. Since contexts are units of work, the fact that you need to do this at all and are having context scoping issues suggests you might want to take a broader look at your design.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top