MiniProfiler with EF “model first” edmx model

后端 未结 2 2183
萌比男神i
萌比男神i 2020-12-28 21:14

I\'m trying to get MiniProfiler to profile my database access but I\'m running into problems. All the help I see out there seems to be for \"code first\" entity framework co

相关标签:
2条回答
  • 2020-12-28 21:30

    I'm having the same issue. It appears that you must add the following to your web.config, however, for me this causes the w3wp.exe process to crash (and the web server in visual studio, for local requests). It doesn't seem like something that is happening to anyone else, so it might work for you (make sure to insert the actual version of the profiler you are using).

    <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>
    
    0 讨论(0)
  • 2020-12-28 21:36

    Try like this:

    var connectionString = ConfigurationManager
        .ConnectionStrings["MyConnectionString"]
        .ConnectionString;
    var ecsb = new EntityConnectionStringBuilder(connectionString);
    var sqlConn = new SqlConnection(ecsb.ProviderConnectionString);
    var pConn = ProfiledDbConnection.Get(sqlConn, MiniProfiler.Current);
    var context = ObjectContextUtils.CreateObjectContext<CYEntities>(pConn);
    
    0 讨论(0)
提交回复
热议问题