I’m using Entity Framework 6 and have an Order entity with a navigation collection property for Products. My goal is to load an Order with tracking enabled but load the Products separately with additional filtering. After loading the Order and the relevant Products, I manually set the Products property on the Order (i.e., order.Products = loadedProducts).
Here is the problem I am facing:
When I manually set the Products property on the Order, Entity Framework registers this navigation property as changed. This means that when I call SaveChanges, EF will attempt to update the Products collection in the database, which I want to avoid. The behavior should be as if Entity Framework loaded the Products along with the Order.
How can I manually set the Products navigation property on the Order without marking it as modified?