开发者

Setup of mvc-mini-profiler for EF-db- first

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 MvcMiniP开发者_运维百科rofiler 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...


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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜