SQLite的PRAGMA foreign_keys问题
-
22-07-2019 - |
解决方案
要解决这个问题,我在SQLiteConnection类添加一个“外键”属性的ConnectionString。
外键= ON 外键= OFF
其他提示
您不需要修改System.Data.SQLite,如果你想使用最新版本的SQLite,只需使用System.Data.SQLite的ManagedOnly版本,然后只更新最新版本的sqlite3.dll。为了使外国键的支持,我只是执行一个SQL语句,使外键的支持。 e.g。
string databasePath = "Your database path here";
string connectionString = "Data Source=" + databasePath;
connection = new SQLiteConnection(connectionString);
connection.Open();
const string sqlString = "PRAGMA foreign_keys = ON;";
SQLiteCommand command = new SQLiteCommand(sqlString, connection);
command.ExecuteNonQuery();
不隶属于 StackOverflow