实体框架核心中的嵌套事务

时间:2019-02-27 09:59:23

标签: .net entity-framework .net-core transactions entity-framework-core

使用System.Transaction,您可以嵌套TransactionScope,例如:

using (var tran1 = new TransactionScope())
{
    // modify context

    using (var tran2 = new TransactionScope())
    {
        // modify context
        tran2.Complete();
    }

    tran1.Complete();
}

如何使用DbContext.Database.BeginTransaction()在Entity Framework Core 2.1中模拟这种行为?

0 个答案:

没有答案