MiniProfiler设置 - 在调用'get_ProviderFactory'方法后返回null [英] MiniProfiler setup - A null was returned after calling the 'get_ProviderFactory' method
问题描述
在MiniProfiler挣扎几个小时后, >在
a $ b'b'StackExchange.Profiling.Data.ProfiledDbConnection'的
a商店提供者实例上调用'get_ProviderFactory'方法后,返回null。商店
提供商可能无法正常运行。
我通过了许多SO帖子,但迄今没有任何工作, 这个发布大概相同的错误,但配置不同,没有答案。现在我知道 ProfiledDbConnection
不会覆盖 DbProviderFactory
,它的父类 DbConnection
在执行 DbProviderFactory
时返回null,所以错误是可以预期的,但它应该以某种方式工作。有一个 MiniProfilerEF.Initialize()
,但它的接缝只能用于CodeFirst,我正在使用DatabaseFirst方法。
我已经安装了MiniProfiler,MiniProfiler.EF,MiniProfilerMVC3 nuget包。这里是我的代码:
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 Server
任何想法?
所以,来自您对为EF-db-首先设置mvc-mini-profiler的评论的评论,您是否尝试删除Mini Profiler专用包装?
var profiled = new ProfiledDbConnection(sqlConnection,MiniProfiler.Current);
var db = new DbContext(profiled,true);
db.Set< Customer>()。ToList();
相反,只需添加
protected void Application_Start()
{
//任何其他代码
MiniProfilerEF.Initialize();
}
然后进行标准数据库访问?
using(var db = new WordsEntities()){
var posts = db.Customer.Take(4);
//更多代码
}
After hours of struggling with MiniProfiler to make it profile the Database queries, I have no luck and I'm getting the error:
A null was returned after calling the 'get_ProviderFactory' method on a store provider instance of type 'StackExchange.Profiling.Data.ProfiledDbConnection'. The store provider might not be functioning correctly.
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.
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();
And I'm using asp.net mvc4, EF5, DatabseFirst, MiniProfiler 2.1.0.0, Sql Server
Any Idea?
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();
Instead, just adding
protected void Application_Start()
{
// any other code
MiniProfilerEF.Initialize();
}
and then doing standard db access?
using (var db = new WordsEntities()) {
var posts = db.Customer.Take(4);
// more code
}
这篇关于MiniProfiler设置 - 在调用'get_ProviderFactory'方法后返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!