I'm using Entity Framework with a TransactionScope. It looks like I'm having a problem involving all of my changes not rolling back if there is a deadlock issue once calling the Complete() method for the TransactionScope. Note, within this TransactionScope I am updating two separate databases, so could the issue be that it will only rollback the changes for the database that got the deadlock issue?
Code example:
try
{
using (TransactionScope scope = new TransactionScope())
{
//Insert into database1 (getting the deadlock issue)
database1.SaveChanges();
//Update ExternalId (Identity PK from database1) in database2
database2.SaveChanges();
scope.Complete();
}
}
catch (Exception ex)
{
throw;
}
In the above example, database2 gets the ExternalId column updated but the record is never inserted into database1, which is weird because the ExternalId is the identity record that we get when inserting the record into database1.