SQLite 不支援異步 I/O。 異步 ADO.NET 方法會在 Microsoft.Data.Sqlite 中同步執行。 避免呼叫它們。
請改用 預先寫入記錄 來改善效能和並行。
var connection = new SqliteConnection("Data Source=AsyncSample.db");
connection.Open();
// Enable write-ahead logging
var walCommand = connection.CreateCommand();
walCommand.CommandText =
@"
PRAGMA journal_mode = 'wal'
";
walCommand.ExecuteNonQuery();
小提示
預設會在使用 Entity Framework Core 建立的資料庫上啟用預先寫入記錄。