My customer business object is an aggregate root for a collection of addresses.
public class Customer {
Public Customer {Addresses = new List<Address>}
public virtual List<Address> Addresses { get; set; }
// other properties
}
Public class Address {
public virtual Customer customer {get;set;}
[NotMapped]
// other properties
}
My context contains
public DBSet<Customer> Customers {get;set;}
but no DBSet for Address because I want the customer to be the aggregate root.
However when I use
Customer.Addresses.RemoveAll(x=>x.TaggedToDelete)
The Customer_Id in the Address table is set to null instead of the Address being removed from the database.
How do I remove the address from the database using the aggregate root?
I had a look at How to remove child one to many related records in EF code first database?
but it uses a DBSet for the child record.