Hi All -
I am using Entity Framework to do some inserts/updates into my database. When I create new Entity Objects and then call SaveChanges(), everything works and dbMonitor shows all of the executed commands. However, when I wrap this same code in a TransactionScope, none of the db activity is showing the dbMonitor. Does anyone know why this is happening, and how to get dbMonitor to show this?
thanks,
Mark
dbMonitor and TransactionScope issue
I have just made a test and the SQL statements sent to database were correct.
I am using the latest 5.70.152 build of dotConnect for Oracle and DBMonitor 3.0.2. Here is the code I was using to reproduce the problem.
Could you please make changes in my code to reproduce the problem and post the changed code here?
I am using the latest 5.70.152 build of dotConnect for Oracle and DBMonitor 3.0.2. Here is the code I was using to reproduce the problem.
Could you please make changes in my code to reproduce the problem and post the changed code here?
Code: Select all
OracleMonitor mon = new OracleMonitor();
mon.TraceEvent += new Devart.Common.MonitorEventHandler(mon_TraceEvent);
mon.IsActive = true;
using (DataModel1Entities db = new DataModel1Entities()) {
using (TransactionScope t = new TransactionScope()) {
Dept d = new Dept
{
Deptno = 1,
Dname = "montest",
Loc = "montest"
};
db.AddToDepts(d);
db.SaveChanges();
t.Complete();
}
}
Previously I had created the OracleMonitor within the Initialization constructor for my Entities. With the dbMonitor created there, the dbMonitor was working for and showing all calls to the db, except it wasn't showing any commands sent to the db that were within a transactionscope.
I've moved the created of the OracleMonitor to within the method that has the transactionscope, and now the dbMonitor shows the activity.
One further question on this though, while I don't see an explicit transaction in the dbMonitor, when I wrap my code in a TransactionScope, does DevArt provider automatically create a transaction in oracle? Ie: if an exception is thrown in my code before getting to t.Complete(), should the transaction commit/rollback?
I've moved the created of the OracleMonitor to within the method that has the transactionscope, and now the dbMonitor shows the activity.
One further question on this though, while I don't see an explicit transaction in the dbMonitor, when I wrap my code in a TransactionScope, does DevArt provider automatically create a transaction in oracle? Ie: if an exception is thrown in my code before getting to t.Complete(), should the transaction commit/rollback?