I'm trying to use Entity Framework Tracing Provider to log the SQL staments generated.
I changed my context class to something like this:
public partial class MyDBContext: DbContext
{
public MyDBContext(string nameOrConnectionString)
: base(EFTracingProviderUtils.CreateTracedEntityConnection(nameOrConnectionString), true)
{
// enable sql tracing
((IObjectContextAdapter) this).ObjectContext.EnableTracing();
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
//DbSets definition....
}
But this doesn't log the SQL statements on the Output window...
Should I had something more in the class or in web.config file? (I'm working on a ASP.NET MVC 4 project)
I using the solution in the following post:Entity Framework 4.1 - EFTracingProvider
but I made some changes that I don't know if they are important:
The class is partial instead of abstract, and the constructor is public instead of protected...
What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…