Entity Framework Cascading Deletes; Set it from the database.
To achieve cascading deletes, one must specify the cascading deletes on the FK relationships from the top level table in the database. The default is not to cascade.
Here is the visual Process in SQL Server Management Studio.
- Select the top level table which will handle the delete and right click.
- Select design mode.
- Right click any row in the design mode.
- Select Relationships.
- Find all the FK relationships and set them to cascade.
Then in Entity Framework update the edmx file after these changes are made so entity framework knows about the cascading constraint. Once all this is done a cascaded delete is possible using Entity Framework.