Why can't turn off foreign key constraint through entity framework?

Viewed 172

I'd like to turn off the foreign key constraint check in an SQLite database through entity framework (just to migrate a table content to another one with modified columns). The command I use for this is PRAGMA foreign_keys = OFF; (also tried PRAGMA foreign_keys = 0;). The command works fine if I use it through an SQLite Studio, it turns off the the check and I can drop the table.

The problem comes when I try to execute it from the code (C#, WPF, Entity Framework):

var result = dbContext.Database.ExecuteSqlCommand("PRAGMA foreign_keys = OFF;");

The result is always -1 and I can't drop the table because the foreign key constraint fails. I also tried to execute it in a new context, and also in a transaction with and also without the drop query, but it does not turns off the constraint check. What I miss?

0 Answers
Related