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