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?