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 updated the package and now my code no longer compiles. The code that fails to compile is:
public static T GetProfiledContext<T>() where T : System.Data.Objects.ObjectContext
{
var conn = GetStoreConnection<T>();
if (_enableProfiling)
{
conn = ProfiledDbConnection.Get(conn);
}
return ObjectContextUtils.CreateObjectContext<T>(conn);
}
The compilation errors report the following issues:
- 'MvcMiniProfiler.Data.ProfiledDbConnection' does not contain a definition for 'Get'.
- The name 'ObjectContextUtils' does not exist in the current context.
I noticed that I can create an instance of ProfiledDbConnection and pass it the connection and an object of type IDbProfiler, but I am not sure how I should obtain that object.
Regarding ObjectContextUtils, I have no clue of what I am supposed to use.
How can I fix these issues?
Update:
By following @monkeychatter's recommendations, I managed to build the code. I now get the following runtime exception:
A null was returned after calling the 'get_ProviderFactory' method on a store provider instance of type 'MvcMiniProfiler.Data.ProfiledDbConnection'. The store provider might not be functioning correctly.
By inspecting ProfiledDbConnection in ILSpy, I noticed that it no longer overrides the DbProviderFactory. That seems to be the cause of the error, since the base implementation returns null. Has anybody been able to work around this issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…