Provider error using MSDTC with Entity Framework

I have an application that saves to db (using Entity Framework) and saves documents to Sharepoint in one save. I am trying to use MSDTC with TransactionScope.

Part of my EF insert logic involves passing a list of foreign keys to the data layer. The layer retrieves the "foreign key'd" object from the db and then adds it to the main object. The weird thing is that this works correctly for the first foreign key element, but doesn't work for the second with the following message.

Fixing System.Data.EntityException: The underlying provider does not work in Open. ---> System.Transactions.TransactionManagerCommunicationException: Network access for the Distributed Transaction Manager (MSDTC) has been disabled. Enable DTC for Network Access Security Configuration for MSDTC using the Component Services Administrators tool.

MSDTC is enabled and running during the first pass, but not the second. I'm guessing the context gets confused in some way when I make a few select calls?

Here's my logic:

//Create new order

foreach(int lineItemId in lineItems)
{
   //Retrieve the LineItem object from db
   //Add the LineItem object to the Order
}

//Save using EF

      

Perhaps I shouldn't be fetching the object from the db? Am I missing an easy way to reference relationships in EF?

+2


source to share


2 answers


You will need the DTC on the DB server, Sharepoint server, and the machine where the code is running and activated to access the network (right click on Properties in the Distributed Transaction Coordinator

node in Component Services snap-in -in, make sure to Network DTC Access

check and that on each there are checkboxes from the machines Allow Remote Clients

, as well as inbound and outbound messages (you can delete some of them, but start it first).



The first call works because it only talks to the local DTC - as soon as it tries to enlist a tx with the remote DTC it fails.

+6


source


This is actually the same answer as Matt, but graphically



enter image description here

+3


source







All Articles