Is there a way to make the EFTracing provider work with EF 4.1?
EFTracing seems to need an objectcontext and I use dbcontext.
Thanks in advance!
Whilst the previous answers work, I've found them problematic, a much simpler solution is to use the Clutch.Diagnostics.EntityFramework package from NuGet that uses MiniProfiler behind the scenes. It is significantly simpler to get working than EFTracingProvider, and a much more flexible solution.
The project is on GitHub at https://github.com/Kukkimonsuta/Clutch
For EFTracingProvider like functionality install the NuGet package and then implement IDbTracingListener like this:
using System;
using System.Data.Common;
using System.Diagnostics;
using Clutch.Diagnostics.EntityFramework;
///
///
///
public class DbTracingListener : IDbTracingListener
{
///
///
///
///
///
///
///
public void CommandExecuted(DbConnection connection, DbCommand command, object result, TimeSpan duration)
{
Debug.WriteLine(command.CommandText);
Debug.WriteLine(string.Format("Executed in: {0}", duration));
}
///
///
///
///
///
public void CommandExecuting(DbConnection connection, DbCommand command)
{
}
///
///
///
///
///
///
///
public void CommandFailed(DbConnection connection, DbCommand command, Exception exception, TimeSpan duration)
{
}
///
///
///
///
///
///
///
public void CommandFinished(DbConnection connection, DbCommand command, object result, TimeSpan duration)
{
}
}