Mvcminiprofiler and ef

Published on den 11 August 2011

MvcMiniProfiler is an awesome tool for profiling your asp.net application. To get it to work's with EF might be a hassle though.

When I was trying it out I got this message:

Unable to find the requested .Net Framework Data Provider. It may not be installed

After digging around a bit I realized it failed on this line:

        var efConnection = ProfiledDbConnection.Get(GetConnection(connectionString));
            Db = ObjectContextUtils.CreateObjectContext<GmokContext>(efConnection);

If I tried without getting the profiled connection it worked fine so I figured something was up with the providers. There is a section in web.config where you can specify the providers. I added the following:

<system.data>
        <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>
    </system.data>

And now everything was working and I can use MvcMiniProfiler with Entity Framework.

Then feel free to it or if you have any comments or questions mention @MikaelEliasson on Twitter.

CTO and co-founder at Bokio with a background as an elite athlete. Still doing a lot of sports but more for fun.

#development, #web, #orienteering, #running, #cycling, #boardgames, #personaldevelopment