BeginTransaction with IsolationLevel in EF Core

半城伤御伤魂 提交于 2020-04-09 18:41:12

问题


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:


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.



来源:https://stackoverflow.com/questions/55208184/begintransaction-with-isolationlevel-in-ef-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!