Hi,
That error has already been mentioned
here, but no solution.
Wen can reproduce by doing this:
//--------------------------------
try
{
//--step 1
try
{
Data1 dat1 = new()
{
field1 = 1,
field2 = 2
};
ctx.Add(dat1);
ctx.SaveChanges();
}
catch(Exception ex)
{
//this leads to an error due to a rule in Oracle-Insert-Trigger, ok so far.
}
//--step 2
var dat2 = ctx.Data2s.AsNoTracking().Where(i => i.Id == 1174902).FirstOrDefault();
dat2.Remark = "bbb";
ctx.Data2s.Update(dat2);
ctx.SaveChanges();
//---
}
catch(Exception ex)
{
//now here's where error "transaction already exists" is thrown
}
//-------------------------------------------
As you can see, we do NOT use EF-Transactions, but rely on the idea, that SaveChanges always opens up a new transaction by Oracle. So even though when the first SaveChanges leads to a rollback, the second SaveChanges should execute OK.
It seems, that a once rollbacked transaction cannot be "reused" by a second call within the same connection.
Actually we do not intend to introduce ef-transaction as this is a very simplified example.
So: Is this really expected behavior or what could we do otherwise?
Thanks