Код: Выделить всё
public class LPO_BLL
{
internal Context1 _context1 = null;
internal Context2 _Context2 = null;
public LPO_Detail_BLL(Context1 context1, Context2 context2)
{
_context1 = context1;
_context2 = context2;
}
public void Insert(PM_LPO lpo, LPO_Transaction lpo_transaction)
{
using (TransactionScope transaction = new TransactionScope())
{
_context1.LPO.Add(lpo);
_context1.SaveChanges();
_context2.LPO_Transaction.Add(lpo_transaction);
_context2.SaveChanges(); // I am getting error here...
transaction.Complete();
}
}
}
Код: Выделить всё
LPO lpo = new LPO();
//setting properties of lpo
LPO_Transaction lpo_trans = new LPO_Transaction();
//setting properties of lpo_trans
Context1 _context1 = new Context1();
//Opening _context1 connection and etc
Context2 _context2 = new Context2();
//Opening _context2 connection and etc
LPO_BLL lpo_bll = new LPO_BLL(_context1, _context2);
lpo_bll.Insert(lpo,lpo_trans);
Сбой базового поставщика при EnlistTransaction
После трехчасового поиска в Интернете и испробования различных методов тестирования и пробных версий я решил разместить это на SO. На данный момент я нашел эти две ссылки немного ближе:
http://social.msdn.microsoft.com/Forums ... ac6f7-6513 -4c87-828a-00e0b88285bc/the-underlying-provider-failed-on-enlisttransaction?forum=adodotnetentityframework
TransactionScope — у базового поставщика произошел сбой при EnlistTransaction. MSDTC прерывается
Подробнее здесь: https://stackoverflow.com/questions/204 ... -framework
Мобильная версия