非同步限制

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 所建立的資料庫上啟用預寫記錄。