I have two different entities of different databases.
In my process I want to manipulate both databases, and the whole process must be in transaction.
I have tried with TransactionScope. It works fine for single entity.
var entity1 = clsProject.GetEntity1();
var entity2 = clsProject.GetEntity2();
System.Transactions.TransactionScope tranScope = new System.Transactions.TransactionScope();
entity1.Connection.Open();
entity2.Connection.Open();
//Do operations
entity1.SaveChanges(false);
entity2.SaveChanges(false);
tranScope.Complete();
entity1.AcceptAllChanges();
entity2.AcceptAllChanges();
But, it raises an error at this line:entity2.Connection.Open();
Error Message: The underlying provider failed on Open.
Inner Exception: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025)
Please give your ideas for this.
Thanks in Advance,
Naresh Goradara
If your second database is on another server you need to turn on Distributed Transaction Coordinator on both servers, and TransactionScope will work.