How to run two Entity Framework Contexts inside TransactionScope without MSDTC?

前端 未结 3 1020
無奈伤痛
無奈伤痛 2021-02-07 09:39

This problem is not readily reproducible in a simple example here but was wondering if anyone has any experience and tips, here is the issue:

  • using Entity
3条回答
  •  南旧
    南旧 (楼主)
    2021-02-07 10:30

    Well, the problem is quite easy.

    If you are using sql server 2008 you should not have that problem because you have promotable transaction, and as .NET knows that you are using the same persistence store (the database) it wont promote it to DTC and commit it as local. look into promotable transaction with sql server 2008.

    As far as I know Oracle is working in its driver to support promotable transactions, but I do not know the state, MS oracle driver does not support it. http://www.oracle.com/technology/tech/windows/odpnet/col/odp.net_11.1.0.7.20_twp.pdf

    If you are using a driver that do not support promotable transactions it is impossible for .NET to use local transaction doing two connections. You should change your architecture or convince the database admin for installing MSDTC.

提交回复
热议问题