c# - Entity Framework: delete record with its sub-records -


I have a table with 3 columns: ID, name, ParentID.

How can I remove a specific record with all my children (n levels deep)?

Using the unit framework 3.5.

This table is self-referencing, this application is argument, it is not expressed in the SQL definition, and therefore EF has not understood.

These records will require you to write a regular EFF that starts with the top and Load all the sub items, then mark all these items as deleted, then save the change call .

To delete an item:

  context.DeleteObject (item); Context.SaveChanges ();  

Comments