use*_*346 5 asp.net-mvc-4 entity-framework-6
我试图将一个MiniProfiler连接到一个先使用EF6代码的现有项目,aaaand它只是让我疯了:)
问题是默认情况下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.
Run Code Online (Sandbox Code Playgroud)
有没有人遇到过类似的问题?谢谢!
EF6 nuget 已发布。它可以在这里找到,并且可以使用安装Install-Package MiniProfiler.EF6 -Pre
要初始化,只需在应用程序启动逻辑中调用以下代码:
using StackExchange.Profiling.EntityFramework6;
...
protected void Application_Start()
{
MiniProfilerEF6.Initialize();
}
Run Code Online (Sandbox Code Playgroud)
请务必在以任何方式使用 EF 之前调用此函数。