Problem with cascade delete using Entity Framework and System.Data.SQLite Problem with cascade delete using Entity Framework and System.Data.SQLite sqlite sqlite

Problem with cascade delete using Entity Framework and System.Data.SQLite


I just dealt with this exact issue. It turned out that when I used EF to Update model from database... option, it didn't properly get the "Cascade" rule for on delete.

Try going to your EF database model, click the association that is causing the problem, then make sure that the End1 OnDelete (could be End2, depends on database scheme) is set to Cascade.


I was having the same problem with SQL Server. When I tried to update mode from database, it didn't pick up the cascade rules. Note that the rules were added after the model was already created. I even tried deleting a table from the model and adding it back in. That had the same effect - no cascade rules.

However, when I created a brand new model with the same exact tables, it picked up the cascade rules. So my solution was just to delete the old model and create a new one with the same name, etc.

I guess is that there is something wrong with the update model from database process.


Sounds like a provider bug to me. The cascade should be picked up from the DB. Try it with SQL Server; you'll see it works there. You should report this to whoever wrote your SQLite provider.