According to http://sqlite.org/pragma.html#pragma_foreign_keys:
As of SQLite version 3.6.19, the default setting for foreign key enforcement is OFF. However, that might change in a future release of SQLite.
As for now, this still defaults to false.
CL already told you that foreign_keys
setting is "per connection" - what it means is that every time you make a new connection to the SQLite database, the foreign_keys
pragma is set to default value, which is false
.
What you need to do is to execute PRAGMA foreign_keys = 1;
after every connection you make to the SQLite, so foreign keys are honored by your C# application.
This is actually what SQLiteStudio does internally and that's why it works there.