BeginTransaction with IsolationLevel in EF Core

entity-framework entity-framework-core isolation-level

Question

I'm trying to rewrite old library to use EntityFramework Core and I can't figure out how to begin transaction with specific isolation level.

Previously I was able to do something like this:

DbContext.Database.BeginTransaction(IsolationLevel.Snapshot);

What is alternative implementation in the EntityFramework Core?

1
8
3/17/2019 2:32:43 PM

Accepted Answer

The EF Core code is exactly the same.

DbContext.Database.BeginTransaction(IsolationLevel.Snapshot);

The only difference is that in EF Core the method with isolation level (as many others) is an extension method, defined in RelationalDatabaseFacadeExtensions class, and importantly, located in Microsoft.EntityFrameworkCore.Relational assembly.

So if you have using Microsoft.EntityFrameworkCore; and don't see it, add reference to the Microsoft.EntityFrameworkCore.Relational.dll assembly / package.

9
3/17/2019 2:54:20 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow