3

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.

user1470240
  • 580
  • 3
  • 19
  • I'm not sure I'd be in a hurry to let a remote workstation get involved in a DTC operation - that sounds risky; but: does dtcping work from that workstation to the server? – Marc Gravell Mar 02 '18 at 09:13
  • And do you need to get DTC involved at all? Since databases are on the same server, maybe you can do that without DTC? – Evk Mar 02 '18 at 09:21
  • @MarcGravell Played arround with the dtcping utitlity an came to a conclusion - see thread answer – user1470240 Mar 05 '18 at 07:29
  • @Evk The dtc is implicitly raised from by the .NET transaction framework ..., so actually I cannot influence its behavoiur ... – user1470240 Mar 05 '18 at 07:31
  • I heard that you can use the same connection string and then use ChangeDatabase method. In that case, because connection strings are identical - DTC should not be involved. – Evk Mar 05 '18 at 07:34

1 Answers1

2

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!

user1470240
  • 580
  • 3
  • 19