I have basicly the same Situation as here described here Multiple databases(datacontext) on same server without MS DTC
like:
using (var transaction = new TransactionScope())
{
using (var entities = new ContextA())
{
// do smth. here
}
using (var entities = new ContextB())
{
// do smth. there
}
}
Both, ContextB and ContextA are located on the same MS SQL Server (V. 13.0.4206.0). The c# code is executed from remote Workstation. Server and Worksation are both in same domain network. But when ContextB is trying to do it's first manipulation, it raises the following error:
The MSDTC transaction manager was unable to pull the transaction from the source transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers. (Exception from HRESULT: 0x8004D02B)
It does not make any difference if I change the order of tasks; say first doing smth. on ContextB, then on ContextA: In that case the error raises when manipulating database from ContextA. Without transaction scope all works fine (but of course without transaction). I've checked firewall settings on Server: Predefined rule for Distributed Transaction Coordinator are enabled for domain and private network. I've checked also DTC properites:
Network DTC Access: true
Allow Inbound: true
AllowOutbound: true
What is wrong? It looks so simple, did I oversee something?
Thank you for your answers.
Solved: Needs to activate predefined firewall rule 'Distributed Transaction Coordinator' on Worksation, where the c# code runs, too.
I wasn't aware that the database server will open a connection back to the transaction initializer (which was my workstation). It seems in this situation, that the transaction initializer inherits the role as coordinator - not the server.
Thank you for the given hints!
User contributions licensed under CC BY-SA 3.0