Why is TransactionScope using a distributed transaction when I am only using LinqToSql and Ado.Net

后端 未结 1 731
暗喜
暗喜 2021-01-20 19:00

We are having problems on one machine, with the error message:

\"MSDTC on server XXX is unavailable.\"

The code is using a T

1条回答
  •  执笔经年
    2021-01-20 19:50

    This almost always happens when your transaction uses more than one database connection. So, let's say you are updating two tables. You might update the first table using one connection but update the second table using a different second connection. This will cause the transaction to be escalated to MSDTC, even using a TransactionScope object.

    The way we got around this is when performing transactions, we use a single database context object for all our writes. This eliminated the escalation. Since doing this, we've never had the MSDTC message appear.

    Randy

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