Lazy loading is enabled in my Entity Framework model (using EF 6.1 with ObjectContext), which also includes a number of navigation settings.
// Orders is a navigation property (collection), which, when first iterated, // loads the collection of Order entities from the DB var orders = Customer.Orders.ToList();
I wish to have a detachable component in my app for performance reasons.
entities and let them to be discarded:
MyContext.Detach(order1); MyContext.Detach(order2); MyContext.Detach(order3);
However, I've discovered that when I merely disconnect a portion of the child entities—that is, not all of them—the following repetition of
It not function since the detached entities are not included in the collection that is returned.
How can I build code to obtain the
causing it to reload and re-attach all entities, including those that were previously detached, in order for the navigation property to recover and function properly in this circumstance?
I've tried adjusting things manually
, however it doesn't work either. Somewhere inside of EF, the entities are not re-loaded.
it just resets to