BeginTransaction
method is used to manage transactions in Entity Framework 6. It allows to set isolation level for transaction as you may see in code below (just a sample):
using (var context = new DataContext())
{
using (var transaction = context.Database.BeginTransaction(IsolationLevel.Serializable))
{
context.Entities.Add(new Entity());
context.SaveChanges();
transaction.Commit();
}
}
The problem is: when I use SQL Server Profiler, I cann't find any information about isolation level for real SQL transaction.
Attempt #1:
I tried to trace ALL kinds of events and search by "isolation" keyword in trace results. Only two events I found:
EventClass TextData
-------------------------------------------------------------
ExistingConnection set transaction isolation level read committed
AuditLogin set transaction isolation level read committed
READ COMMITTED
is always in these events. So it is not about my code, because IsolationLevel.Serializable
is set above.
Attempt #2:
For the transaction has been started and not committed yet, it is possible to take SPID
and manually select real isolation level from dm_exec_sessions
view:
SELECT transaction_isolation_level
FROM sys.dm_exec_sessions
WHERE session_id = @Tran_SPID
This is very undesirable way.
Is it possible to record isolation level for any EF-generated transaction/session in profiler directly? Maybe I just use wrong tool?
P.S. Entity Framework 6.1.3 and MS SQL Server 2012 on board.