Mini profiler upgrade from 1.7 to 1.9 breaks existing code

前端 未结 1 1092
长情又很酷
长情又很酷 2020-12-17 21:25

I have a asp.net project that uses mvc-mini-profiler. I was using version 1.7 of the NuGet package and I noticed that there is an updated package whose version is 1.9. I upd

相关标签:
1条回答
  • 2020-12-17 21:42

    I just went through the same and unfortunately most/all documentation shows the 'old' way. The majority of this functionality has been moved to the ProfiledDbConnection class itself. To get the ObjectContext extension on ProfiledDbConnection you also need to reference an assembly from the nuget package 'MiniProfiler.EF'. Below are the edits to get the equivalent code in 1.9.

    //reference extension from MvcMiniProfiler.Data
    using MvcMiniProfiler.Data;
    
    var conn = GetStoreConnection<T>();   
    if (_enableProfiling)   
    {   
        //conn = ProfiledDbConnection.Get(conn);   
        conn = new ProfiledDbConnection(conn, MiniProfiler.Current);
    }   
    //return ObjectContextUtils.CreateObjectContext<T>(conn);
    return conn.CreateObjectContext<T>();
    

    Update: Per your updated question I would replace the line in my previous solution as below. This includes an override to fix up the ProviderFactory issue:

        //conn = new ProfiledDbConnection(conn, MiniProfiler.Current);
        conn = new EFProfiledDbConnection(conn, MiniProfiler.Current);
    
    0 讨论(0)
提交回复
热议问题