EF6 How to get navigation properties when Parent entity in detach state.

Amol M 1 Reputation point
2022-04-29T06:26:51.747+00:00

I am using detach for performance, I need solutions to load navigation property when parent entity is in detach state. I read many article looks like not possible just trying my luck if anyone has any idea.

I want to maintain all data after detach.

Thanks in advance

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,402 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 24,296 Reputation points Microsoft Vendor
    2022-05-03T01:23:31.417+00:00

    @Amol M , Welcome to Microsoft Q&A, you could refer to the question restoring navigation property after detaching entities to restore the properties after detaching the entities.

    Code:

    context.LoadProperty(customer, c => c.Orders, MergeOption.OverwriteChanges);