ETW - ADO tracing does not work after EF
-
After I got ETW working I fell into this unexpected behavior: When I run a program where I first do some plain ADO.NET calls, and then EF calls, both are logged. BUT when I first do the EF calls, the ADO.NET calls that come afterwards aren't logged anymore. In the test program below executing readADO() before ReadEF() will give me all the 4 select statements in the log file (including "select name from sales.store"), switching the 2 functions will not display the ADO.NET SQL statement anymore. Tracing setup: ctrl.guid.adonet
{7ACDCAC8-8947-F88A-E51A-24018F5129EF} 0xFFFFFFFF 5 ADONETDIAG.ETW
{914ABDE2-171E-C600-3348-C514171DE148} 0xFFFFFFFF 5 System.Data.1
{A68D8BB7-4F92-9A7A-D50B-CEC0F44C4808} 0xFFFFFFFF 5 System.Data.Entity.1
{C9996FA5-C06F-F20C-8A20-69B3BA392315} 0xFFFFFFFF 5 System.Data.SNI.1
{BA798F36-2325-EC5B-ECF8-76958A2AF9B5} 0xFFFFFFFF 5 SQLNCLI.1test.bat
logman start adonettrace -pf .\ctrl.guid.adonet -o adonettrace.etl -ets
"C:\Users\DBEGAVE\Documents\visual studio 2012\Projects\TestETW\TestETW\bin\Debug\testETW.exe"
logman stop adonettrace -ets
tracerpt -of csv .\adonettrace.etl -y
perfview -BufferSize:2048 .\adonettrace.etlAny thoughts? Thanks, Gaston
static void Main(string[] args)
{
ReadADO();
ReadEF();
}private static void ReadADO()
{
using (SqlConnection conn = new SqlConnection(@"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=AdventureWorks2008R2;Data Source=.\sqlexpress"))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select name from sales.store";
using (SqlDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
Console.WriteLine(rdr.GetString(0));
}
}
}
}
}private static void ReadEF()
{
using (AdventureWorksEntities db = new AdventureWorksEntities())
{
foreach (Store s in db.Stores)
{
Console.WriteLine(s.Name);
}
}
}