使用EntityFramework 6 Code First的MiniProfiler

5

我试图将MiniProfiler连接到一个使用EF6 Code First的现有项目中,但它让我感到很抓狂 :)

问题是默认情况下MiniProfiler与EF 4.1一起使用,而对于6.0版本,他们实现了一种快速解决方案https://github.com/SamSaffron/MiniProfiler/pull/134

但似乎对我没有用。每次启动应用程序时,我都会收到以下异常:

System.InvalidOperationException: The Entity Framework provider type 'StackExchange.Profiling.Data.EFProfiledSqlClientDbProviderServices, MiniProfiler.EntityFramework6' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.

有人遇到过类似的问题吗? 谢谢!

1个回答

4
EF6 nuget已经发布。您可以在此处获取,并且可以使用Install-Package MiniProfiler.EF6 -Pre进行安装。
要初始化,请在应用程序启动逻辑中简单调用以下内容:
using StackExchange.Profiling.EntityFramework6;

...

protected void Application_Start()
{
    MiniProfilerEF6.Initialize();
}

一定要在任何使用EF之前调用此方法。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接