5

I'm trying to use the mini-profiler with old-style EF code - database-first.

So far:

  • I've created a db context using:

        string connectionString = GetConnectionString();
        var connection = new EntityConnection(connectionString);
        var profiledConnection = ProfiledDbConnection.Get(connection);
        _context = profiledConnection.CreateObjectContext<MyEntitiesType>();
    
  • but then I hit a "Unable to find the requested .Net Framework Data Provider. It may not be installed." which I worked around using a <system.data> reference to the MvcMiniProfiler provider:

     <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" />
        </DbProviderFactories>
      </system.data>
    
  • but now I'm hitting a stack overflow somewhere in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\Data\ProfiledDbProviderServices.cs. Looking at the latest source I'm wondering if I've somehow got the setup wrong for this - if somehow my profiled connection is containing another profiled connection is containing....

Any help/advice?


Update - looking at http://code.google.com/p/mvc-mini-profiler/wiki/FrequentlyAskedQuestions at least one other person has seen the same sort of problem with 1.7 - although (s)he's doing code first. I'll keep playing to see if I can work out what to do...

Stuart
  • 66,722
  • 7
  • 114
  • 165
  • does this help? http://benjii.me/2011/07/using-the-mvc-mini-profiler-with-entity-framework/ there is another proposal for a way to profile EF – Sam Saffron Jul 27 '11 at 22:24
  • Maybe - will have to try it out - will either happen late tomorrow night or Friday (at a client site all day tomorrow) – Stuart Jul 27 '11 at 22:50
  • Did you ever figure out how to set it up with EF database first? – RyanW Aug 26 '11 at 20:06
  • @RyanW - no - I think I'll download the source and try properly at some point (sorry for delay - been away on hols) – Stuart Aug 31 '11 at 16:33

1 Answers1

4

Try 1.9. With the update, I just added the new Initialize method in Application_Start and removed the DbProviderFactories config section and now I have SQL profiling with EF (2 databases even, one with code first and one with database first).

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

    MiniProfilerEF.Initialize();
}
RyanW
  • 5,338
  • 4
  • 46
  • 58