SQLite PRAGMA foreign_keysの質問
-
22-07-2019 - |
解決
これを修正するために、SQLiteConnectionクラスのConnectionStringに「外部キー」プロパティを追加しました。
外部キー= ON 外部キー= OFF
他のヒント
最新バージョンのSQLiteを使用する場合は、System.Data.SQLiteを変更する必要はありません。System.Data.SQLiteのManagedOnlyバージョンを使用し、sqlite3.dllを最新バージョンに置き換えるだけです。外部キーのサポートを有効にするには、外部キーのサポートを有効にするsqlステートメントを実行するだけです。例:
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