title: Cascade delete in EF4 CTP5 Code First performs update on child records
body: <p>Using the method described <a href="https://stackoverflow.com/questions/4593591/entity-framework-ctp5-code-first-many-to-many-with-cascade-delete">here</a>, I am attempting to delete a parent record and all the associated child records.  However, what happens is the parent is deleted as expected, but child record key field is updated to NULL instead of being deleted. </p>
  
  <p>I also set the child table foreign key's Delete Rule to Cascade, and deleting from the parent table in SQL Server Management performs the cascade delete as expected.</p>
  
  <p>I started by following this <a href="http://blogs.msdn.com/b/adonet/archive/2010/12/14/ef-feature-ctp5-code-first-walkthrough.aspx" rel="nofollow noreferrer">walkthough</a>, and modifying the code to perform a delete.</p>
  
  <p>this is the code:</p>
  
  <pre><code> using (var db = new ProductContext())
   {
       var food = db.Categories.Find("FOOD");
       ((IObjectContextAdapter)db).ObjectContext.LoadProperty(food, f =&gt; f.Products);
  
       db.Categories.Remove(food);
      int recordsAffected = db.SaveChanges();
  </code></pre>
  
  <p>Is there something I'm missing?  Or is orphaned child records the intended result?</p>