My model is a simple person table with one column FIRSTNAME. Below are two methods - one that using a Required TransactionScope and one that uses no TransactionScope. I can call each method by itself repeatedly, but as soon as I call the Required one and then call the No Transaction one I get an error
when trying to call SaveChanges in the DoNoTransaction. The Stack trace is thisORA-24776: cannot start a new transaction
Devart.Data.Oracle.an.b(int A_0 = -1)
Devart.Data.Oracle.at.c(int A_0 = -1)
Devart.Data.Oracle.at.a(bool A_0 = false)
Devart.Data.Oracle.OracleInternalConnection.Commit()
Devart.Data.Oracle.OracleTransaction.Commit()
System.Data.EntityClient.EntityTransaction.Commit()
System.Data.Objects.ObjectContext.SaveChanges(System.Data.Objects.SaveOptions options = {unknown})
Code: Select all
public void DoRequiredScope()
{
try
{
TransactionOptions transOptions = new TransactionOptions();
transOptions.IsolationLevel = IsolationLevel.ReadCommitted;
transOptions.Timeout = new TimeSpan(0, 0, 30);
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transOptions))
{
Debug.WriteLine("Current Transaction is " + Transaction.Current.TransactionInformation.LocalIdentifier);
Transaction.Current.TransactionCompleted += Current_TransactionCompleted;
using (Entities entities = new Entities())
{
entities.Connection.Open();
PERSON app = entities.PERSON.First();
app.FIRSTNAME = "A Change w/txn";
Console.WriteLine(app.FIRSTNAME);
entities.SaveChanges();
entities.Connection.Close();
}
ts.Complete();
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
//throw;
}
}
public void DoNoTransaction()
{
try
{
using (Entities entities = new Entities())
{
entities.Connection.Open();
PERSON app = entities.PERSON.First();
app.FIRSTNAME = "A Change w/o txn";
Console.WriteLine(app.FIRSTNAME);
entities.SaveChanges();
entities.Connection.Close();
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
Debug.WriteLine(ex.StackTrace);
}
}
Any help/explanation would be appreciated
Bryan
________