web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

XRM Context losing track of entity

(0) ShareShare
ReportReport
Posted on by 400

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)
  • Suggested answer
    gfritz Profile Picture
    on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans