views:

313

answers:

1

I have an app that is saving to a db (using Entity Framework) and saving documents to Sharepoint in a single save. I'm attempting to use MSDTC with a TransactionScope.

Part of my EF insert logic includes 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 primary object. The strange thing is, this works correctly for the first foreign key'd item, but fails on the second with the following message.

"System.Data.EntityException: The underlying provider failed on Open. ---> System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool."

MSDTC is enabled and works during the first pass through, but not the second. I assume the context is somehow getting confused when I am making several 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 retrieving the object from the db? Am I missing a simple way to reference the relationship in EF?

+4  A: 

You'd need the DTC on the DB server, the Sharepoint server, and the machine running the code to be running and enabled for network access (right-click Properties on the "Distributed Transaction Coordinator" node in the Component Services snap-in, ensure "Network DTC Access" is checked and that "Allow Remote Clients" and Inbound and Outbound communications are checked on each of the machines (you may be able to remove some of these, but get it working first). The first call works because it's only talking to the local DTC- as soon as it tries to enlist the tx with a remote DTC, it fails.

nitzmahone