Using the method described here, 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.
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.
I started by following this walkthough, and modifying the code to perform a delete.
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'm missing? Or is orphaned child records the intended result?