加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-4 – 首先使用EntityFramework 6代码的MiniProfiler

发布时间:2020-12-16 03:29:10 所属栏目:asp.Net 来源:网络整理
导读:我试图将一个MiniProfiler连接到一个先使用EF6代码的现有项目,aaaand它只是让我疯了:) 问题是默认情况下MiniProfiler与EF 4.1一起使用,而对于6.0,他们已经实现了一种快速解决方案https://github.com/SamSaffron/MiniProfiler/pull/134 但似乎它对我不起作用.
我试图将一个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.

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

解决方法

EF6 nuget已经发布.它可用 here,可以使用Install-Package MiniProfiler.EF6 -Pre进行安装

要初始化,只需在应用程序启动逻辑中调用以下内容:

using StackExchange.Profiling.EntityFramework6;

...

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

在以任何方式使用EF之前一定要调用它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读