非同期の制限事項Async limitations
SQLite では非同期 I/O はサポートされません。SQLite doesn't support asynchronous I/O. 非同期 ADO.NET メソッドは、Microsoft.Data.Sqlite では同期的に実行されます。Async ADO.NET methods will execute synchronously in Microsoft.Data.Sqlite. これらを呼び出すのは避けてください。Avoid calling them.
代わりに、共有キャッシュと先行書き込みログを使用して、パフォーマンスとコンカレンシーを向上させます。Instead, use a shared cache and write-ahead logging to improve performance and concurrency.
var connection = new SqliteConnection("Data Source=AsyncSample.db;Cache=Shared");
connection.Open();
// Enable write-ahead logging
var walCommand = connection.CreateCommand();
walCommand.CommandText =
@"
PRAGMA journal_mode = 'wal'
";
walCommand.ExecuteNonQuery();
ヒント
Entity Framework Core を使用して作成されたデータベースでは、先行書き込みログが既定で有効になっています。Write-ahead logging is enabled by default on databases created using Entity Framework Core.