Using the method described here , I am trying to delete the parent record and all related child records. However, what happens is that the parent is deleted as expected, but the child field of the record key is updated to NULL, not deleted.
I also set an exception for the foreign key of the Delete Rule child table in Cascade, and deleting from the parent table in SQL Server Management performs a cascading delete as expected.
I started with this walkthough and changed the code to do the removal.
this is the code:
using (var db = new ProductContext())
{
var food = db.Categories.Find("FOOD");
((IObjectContextAdapter)db).ObjectContext.LoadProperty(food, f => f.Products);
db.Categories.Remove(food);
int recordsAffected = db.SaveChanges();
Is there something I am missing? Or does an orphaned child write down the intended result?