EF6 wraps every single stored procedure call in its own transaction. How to prevent this?

前端 未结 4 1131
夕颜
夕颜 2020-12-08 14:16

Profiled with SQL Server Profiler: EF 6 wraps every single stored procedure call with BEGIN TRAN and COMMIT TRAN.

Is not it a breaking cha

4条回答
  •  鱼传尺愫
    2020-12-08 14:24

    Just to contribute, I'm using Unity as DI, EF 6.1.3 and database first and I was getting the message: "New transaction is not allowed because there are other threads running in the session" when I called a procedure or a function mapped in my edmx file. The option EnsureTransactionsForFunctionsAndCommands = false fixed the problem. The Max Zerbini's solution worked too, but I would've to use that way for each procedure call.

提交回复
热议问题