4

I am using entity framework with mvc-mini-profiler. After upgrading from mvc-mini-profiler 1.7 to version 1.9 and solving some issues, I managed to compile my project. Now I am getting the following runtime exception:

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

I think the problem might be related with the configured db provider factories, because I had the same issue with version 1.7 and solved it by adding the following to my .config file:

<DbProviderFactories>
    <remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
    <add name="MvcMiniProfiler.Data.ProfiledDbProvider" 
         invariant="MvcMiniProfiler.Data.ProfiledDbProvider" 
         description="MvcMiniProfiler.Data.ProfiledDbProvider" 
         type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler, Version=1.7.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
</DbProviderFactories>

Now I tried to replace the above with the following, but I still get the error:

<DbProviderFactories>
    <remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
    <add name="MvcMiniProfiler.Data.ProfiledDbProvider" 
         invariant="MvcMiniProfiler.Data.ProfiledDbProvider" 
         description="MvcMiniProfiler.Data.ProfiledDbProvider" 
         type="MvcMiniProfiler.Data.EFProfiledDbProviderFactory`1, MvcMiniProfiler.EntityFramework, Version=1.9.1.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
</DbProviderFactories>

What is the correct configuration to solve this issue?

Community
  • 1
  • 1
Antoine Aubry
  • 12,203
  • 10
  • 45
  • 74

1 Answers1

4

Have you tried removing the DbProviderFactories from your .config?

Do you have the initialize in there?

protected void Application_Start()
{
    ....other code

    MiniProfilerEF.Initialize();
}

With 1.9, I just added the Initialize in Start and removed the config section and now I have SQL profiling with EF.

RyanW
  • 5,338
  • 4
  • 46
  • 58
  • That worked, thanks. After fixing this, I noticed an error while loading mini-profiler-includes.*. I have code in the Application_AuthenticateRequest event that hits the database and that code was causing the profiler to throw a NullReferenceException. I had to add code to check that the request is for mini-profiler-includes.* that skips the database access. Is that normal behavior? Version 1.7 had no problem with this. – Antoine Aubry Sep 02 '11 at 17:58
  • Sorry, I've only tried the profiler in an app that's accessing the db in controller methods, nothing higher level yet, so I haven't seen that. Thanks for the accept, glad it worked (sorta). – RyanW Sep 02 '11 at 18:40