问题描述
在与MiniProfiler努力使分析的数据库查询的时间,我没有运气,我得到的错误:
After hours of struggling with MiniProfiler to make it profile the Database queries, I have no luck and I'm getting the error:
一个空于调用get_ProviderFactory方法后返回
类型的存储提供实例
StackExchange.Profiling.Data.ProfiledDbConnection。商店
供应商可能无法正常工作。
我经历了许多有这么职位,但至今没有奏效,像this后大约是相同的错误,但不同的配置和幸福有没有一个答案。现在我知道, ProfiledDbConnection
不覆盖 DbProviderFactory
和它的父类的DbConnection
在它的实施 DbProviderFactory
,所以误差是可预期的,但它应该以某种方式工作返回null。有一个 MiniProfilerEF.Initialize()
,但接缝只为$是可用的C $ cFirst和我使用DatabaseFirst方法。
I got through many SO posts but nothing has worked so far, like this post which is about the same error but with different configuration and well there's not an answer. Now I know that ProfiledDbConnection
is not overriding DbProviderFactory
and it's parent class DbConnection
returns null in it's implementation of DbProviderFactory
so the error is expectable but it should work somehow. There is a MiniProfilerEF.Initialize()
but it seams to be usable for CodeFirst only and I'm using DatabaseFirst approach.
我已经安装了MiniProfiler,MiniProfiler.EF,MiniProfilerMVC3的NuGet包。这里是我的code:
I have installed MiniProfiler, MiniProfiler.EF, MiniProfilerMVC3 nuget packages. And here is my code:
string connectionString = ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;
var sqlConnection = new SqlConnection(connectionString);
var profiled = new ProfiledDbConnection(sqlConnection, MiniProfiler.Current);
var db = new DbContext(profiled, true);
db.Set<Customer>().ToList();
和我使用asp.net mvc4,EF5,DatabseFirst,MiniProfiler 2.1.0.0,SQL服务器
And I'm using asp.net mvc4, EF5, DatabseFirst, MiniProfiler 2.1.0.0, Sql Server
任何想法?
推荐答案
所以,从您的评论即将来临因此,从您的评论即将来临的的设置,你有没有尝试删除特定的探查迷你包装?
So, coming from your comment on So, coming from your comment on Setup of mvc-mini-profiler for EF-db- first, have you tried removing the Mini Profiler-specific wrapper?
var profiled = new ProfiledDbConnection(sqlConnection, MiniProfiler.Current);
var db = new DbContext(profiled, true);
db.Set<Customer>().ToList();
相反,只是添加
protected void Application_Start()
{
// any other code
MiniProfilerEF.Initialize();
}
,然后做标准DB访问?
and then doing standard db access?
using (var db = new WordsEntities()) {
var posts = db.Customer.Take(4);
// more code
}
这篇关于MiniProfiler设置 - 空调用“get_ProviderFactory”方法后返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!