作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
经过数小时的努力,MiniProfiler 使其分析数据库查询,我没有运气,我收到错误:
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.
ProfiledDbConnection
不覆盖
DbProviderFactory
它是父类
DbConnection
在
DbProviderFactory
的实现中返回 null所以错误是可以预料的,但它应该以某种方式起作用。有一个
MiniProfilerEF.Initialize()
但它似乎只能用于 CodeFirst,而我正在使用 DatabaseFirst 方法。
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();
最佳答案
因此,来自您对 Setup of mvc-mini-profiler for EF-db- first 的评论,您是否尝试删除 Mini Profiler 特定的包装器?
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();
}
然后进行标准的数据库访问?
using (var db = new WordsEntities()) {
var posts = db.Customer.Take(4);
// more code
}
关于entity-framework - MiniProfiler 设置 - 调用 'get_ProviderFactory' 方法后返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19195200/
经过数小时的努力,MiniProfiler 使其分析数据库查询,我没有运气,我收到错误: A null was returned after calling the 'get_ProviderFact
我是一名优秀的程序员,十分优秀!