
Hi,
This is just an informational question, I already apply a workaround but very curious about the reason.
Why does the XRMDataContext looses track of an entity?
For example (within the same function en DataContext) :
- You add a new Contact and do SaveChanges
- You add a new Account and do SaveChanges
After those 2 steps you would expect your newly created Contact is still tracked by the context.
But If I update the ParentCustomerId on the contact and mark it as updates via UpdateObject, I receive an exception that my entity is not tracked by the context.
You can easily check this with IsAttached, but why does it detaches from my Context.
I used to work on a project with EF, and we never ran into such an issue when using the same context.
Any Idea's or docs explaining this?
Regards,
Sven Peeters
BELGIUM
*This post is locked for comments
I have the same question (0)A side effect of OrganizationService.SaveChanges() is that all entities are detached from the context automatically. They automatically attach when retrieved, and the automatically detach when saved.
See the first paragraph from the "Attach entities to the context article". :: http://msdn.microsoft.com/en-us/library/gg695783.aspx
This is old, but it deserves a response because it is more of a side-note in the docs.