title: Entity framework code first delete with cascade
body: <p>How do I set up my domain and the LINQ statement so I can delete a record from a database?</p>
  
  <pre><code>public class Category    {
      public int CategoryId { get; set; }
      public string Name { get; set; }
  
      public List&lt;Product&gt; Products{ get; set; }
  
  }
  public class Product {
      public int ProductId { get; set; }
      public string Name { get; set; }
  
      public int CategoryId {get; set; }
      public Category Category{ get; set; }
  }
  </code></pre>
  
  <p>What I'd like to do is delete Category and be able to cascade the delete to all the child products.</p>
  
  <ol>
  <li>Is there any other additional attributes needed in my domain?</li>
  <li>What is the LINQ statement to delete objects without doing a round trip? (I do not want to select, just a direct delete).</li>
  </ol>
  
  <p>Is this the only way to do this?</p>
  
  <pre><code>Category category = new Category() {  CategoryId = 1   } ; 
  context.AttachTo("Category", category);
  context.DeleteObject(category);
  context.Savechanges();
  </code></pre>