Take the 2-minute tour ×

I would like to use MVC Mini Profiler for Entity Framework Connection. The way I did it is like this:

public static XXXXX.DAL.BO.XXXXXEntities GetEntityConnection()
        var conn = ProfiledDbConnection.Get(new EntityConnection(ConfigurationManager.ConnectionStrings["XXXXXEntities"].ConnectionString));
        return ObjectContextUtils.CreateObjectContext<XXXXX.DAL.BO.XXXXXEntities>(conn);

So the following line is to get the Context for the rest of the code:

XXXXX.DAL.BO.XXXXXEntities ctx = GetEntityConnection();

When I attempted to view this site on a browser, however, the WebDev.WebServer40.exe crashed.

Does anyone have any idea why?

Thanks heaps.

P.S. Previously it was

XXXXX.DAL.BO.XXXXXEntities ctx = new XXXXX.DAL.BO.XXXXXEntities();

and it worked fine.

share|improve this question
add comment

2 Answers

try initialising your connection to :

connection = new EFProfiledDbConnection( new EntityConnection(ConfigurationManager.ConnectionStrings["XXXXXEntities"].ConnectionString),

works for me.

share|improve this answer
add comment

If you are able to use the v3.0.10 nuget for EF6, then all you need to do to hook up Entity Framework is

protected void Application_Start()

Using EF 5 or earlier (with the corresponding nuget package) would require you to generate an EFProfiledDbConnection as Anirudh wrote in his answer:

var conn =  new EFProfiledDbConnection(GetConnection(), MiniProfiler.Current);
return ObjectContextUtils.CreateObjectContext<MyModel>(conn);
share|improve this answer
add comment

Your Answer


