BeginTransaction with IsolationLevel in EF Core

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.

Leave a Comment