EntityFrameworkCoreでInMemoryする場合はMicrosoft.EntityFrameworkCore.InMemory
が鉄板のようです。
しかし上記Packageを使う場合、トランザクションが張れないようです。
試しに以下のコードを試してみました。
using (var trn = _context.Database.BeginTransaction())
{
trn.Commit();
}
実行結果は以下の通り。
エラー メッセージ: System.InvalidOperationException : Error generated for warning 'Microsoft.EntityFrameworkCore.Database.Transaction.TransactionIgnoredWarning: Transactions are not supported by the in-memory store. See http://go.microsoft.com/fwlink/?LinkId=800142'. This exception can be suppressed or logged by passing event ID 'InMemoryEventId.TransactionIgnoredWarning' to the 'ConfigureWarnings' method in 'DbContext.OnConfiguring' or 'AddDbContext'.
上記Warningを無視する場合、下記オプションを設定すれば良いそうです。
options .UseInMemoryDatabase() .ConfigureWarnings(w => w.Ignore(InMemoryEventId.TransactionIgnoredWarning))
おわり
弊社だと一生EntityFramework使う機会なさそう...