How do you use the mvc-mini-profiler with Entity F

2019-04-05 00:02发布

问题:

I am trying to use the mvc-mini-profiler with MVC3 and keep getting the following error

Unable to determine the provider name for connection of type 'MvcMiniProfiler.Data.ProfiledDbConnection'

Below is the code that I am using to try and instatiate my Context.

DbConnection conn = new MySqlConnection(
    ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);

var profiledConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(conn);
return new DB(profiledConnection);

And here is the DB Context Class.

public class DB:DbContext, Stats.Data.IDB
{
    public DB(DbConnection conn)
        : base(conn, true)
    {

    }...

回答1:

As of version 1.5 this is now supported see: http://code.google.com/p/mvc-mini-profiler

The step to configure it are listed here: Using mvc-mini-profiler database profiling with Entity Framework Code First