public void ChangeSet_DontLoadUnloadedAssociations() { NorthwindEntityContainer entities = new NorthwindEntityContainer(); EntitySet <Order> orders = entities.GetEntitySet <Order>(); EntitySet <Order_Detail> details = entities.GetEntitySet <Order_Detail>(); // add a few existing entities Order order = new Order { OrderID = 1 }; Order_Detail detail = new Order_Detail { OrderID = 1, ProductID = 1 }; entities.LoadEntities(new Entity[] { order, detail }); // modify both entities order.Freight = 5; detail.Quantity = 5; IEntityRef er = detail.GetEntityRef("Order"); Assert.IsNull(er); IEntityCollection ec = order.Order_Details; Assert.IsFalse(ec.HasValues); EntityChangeSet cs = entities.GetChanges(); Assert.AreEqual(2, cs.ModifiedEntities.Count); // after computing the changeset, no association members // should have been loaded er = detail.GetEntityRef("Order"); Assert.IsNull(er); Assert.IsFalse(ec.HasValues); // after building the operation list, no association members // should have been loaded ChangeSetBuilder.Build(cs); er = detail.GetEntityRef("Order"); Assert.IsNull(er); Assert.IsFalse(ec.HasValues); }