BeginTransaction with IsolationLevel in EF Core

前端 未结 1 948
再見小時候
再見小時候 2021-02-07 10:22

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 d

相关标签:
1条回答
  • 2021-02-07 11:05

    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.

    0 讨论(0)
提交回复
热议问题