【发布时间】:2012-06-21 05:24:26
【问题描述】:
我正在尝试将 mvc-mini-profiler 用于 db-first EF,但它无法正常工作。
(注意我使用的是objectcontext,而不是dbcontext)
这是我尝试过的 stackoverflow 列表:
- Setup of mvc-mini-profiler for EF-db- first
- How to get MVC-mini-profiler working on EF 4.1 Database First
版本:
- 实体框架:4.3.1
- MiniProfiler:2.0.2
- MiniProfiler.ef: 2.0.3
这就是我设置 miniprofiler 的方式:
-
我在 Global.asax 中添加了以下内容
protected void Application_BeginRequest( { MiniProfiler.Start(); } protected void Application_EndRequest() { MiniProfiler.Stop(); } protected void Application_Start() { ... MiniProfilerEF.Initialize_EF42(); } -
然后配置一个objectcontext,
var entityConnection = new EntityConnection(ConnectionString); var profiledDbConnection = new EFProfiledDbConnection(entityConnection, MiniProfiler.Current); var context = profiledDbConnection.CreateObjectContext<MyContext>(); var list = context.MyEntities.ToList();
如果我执行这个,运行“context.MyEntities.ToList()”时会出现以下异常
[System.Data.EntityCommandCompliationException]
内部异常中的消息说: EntityClient 不能用于从存储命令树创建命令定义。
我配置错了吗?有什么帮助吗?
谢谢,
【问题讨论】:
-
您可能错过了这篇文章:[在不创建数据库的情况下将 Mini-Profilier 与 EF 4.3 和 MVC 4 一起使用][1] [1]:stackoverflow.com/q/9539946/1437962
标签: entity-framework mvc-mini-profiler database-first