public void Attached_OwnedCollectionRemove() { Models.Company company1; using (var context = new TestDbContext(_connection)) { company1 = context.Companies .Include(p => p.Contacts.Select(m => m.Infos)) .Single(p => p.Id == 2); //} // Simulate detach //company1.Contacts.Remove(company1.Contacts.First()); context.Entry(company1.Contacts.First()).State = EntityState.Deleted; //using (var context = new TestDbContext(_connection)) //{ // Setup mapping //context.Entry(company1).State = EntityState.Modified; context.UpdateGraph(company1, map => map .OwnedCollection(p => p.Contacts, with => with .OwnedCollection(p => p.Infos))); context.SaveChanges(); Assert.IsTrue(context.Companies .Include(p => p.Contacts.Select(m => m.Infos)) .Single(p => p.Id == 2) .Contacts.Count == 0); } }