首先为EF-db设置mvc-mini-profiler [英] Setup of mvc-mini-profiler for EF-db- first
问题描述
我正在尝试将mini-profiler与旧式EF代码一起使用-数据库优先.
I'm trying to use the mini-profiler with old-style EF code - database-first.
到目前为止:
-
我使用以下方法创建了数据库上下文:
I've created a db context using:
string connectionString = GetConnectionString();
var connection = new EntityConnection(connectionString);
var profiledConnection = ProfiledDbConnection.Get(connection);
_context = profiledConnection.CreateObjectContext<MyEntitiesType>();
,但是随后我打了一个找不到所需的.Net Framework数据提供程序.它可能没有安装."
我使用对MvcMiniProfiler提供程序的<system.data>
引用来解决此问题:
but then I hit a "Unable to find the requested .Net Framework Data Provider. It may not be installed."
which I worked around using a <system.data>
reference to the MvcMiniProfiler provider:
<system.data>
<DbProviderFactories>
<remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
<add name="MvcMiniProfiler.Data.ProfiledDbProvider" invariant="MvcMiniProfiler.Data.ProfiledDbProvider" description="MvcMiniProfiler.Data.ProfiledDbProvider" type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler" />
</DbProviderFactories>
</system.data>
,但是现在我遇到了C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\Data\ProfiledDbProviderServices.cs
中某个地方的堆栈溢出.查看最新来源我想知道我是否为此设置错误-如果我的配置文件连接包含另一个配置文件连接....
but now I'm hitting a stack overflow somewhere in C:\Users\sam\Desktop\mvc-mini-profiler\MvcMiniProfiler\Data\ProfiledDbProviderServices.cs
. Looking at the latest source I'm wondering if I've somehow got the setup wrong for this - if somehow my profiled connection is containing another profiled connection is containing....
有任何帮助/建议吗?
更新-查看 http://code.google.com/p/mvc-mini-profiler/wiki/FrequentlyAskedQuestions 至少有一个人也遇到过与1.7类似的问题-尽管他首先在做代码.我会继续玩,看看我是否能解决该怎么办...
Update - looking at http://code.google.com/p/mvc-mini-profiler/wiki/FrequentlyAskedQuestions at least one other person has seen the same sort of problem with 1.7 - although (s)he's doing code first. I'll keep playing to see if I can work out what to do...
推荐答案
尝试1.9.通过更新,我刚刚在Application_Start中添加了新的Initialize方法,并删除了DbProviderFactories config部分,现在我可以使用EF(甚至2个数据库,其中一个首先使用代码,一个首先使用数据库)进行SQL性能分析.
Try 1.9. With the update, I just added the new Initialize method in Application_Start and removed the DbProviderFactories config section and now I have SQL profiling with EF (2 databases even, one with code first and one with database first).
protected void Application_Start()
{
....other code
MiniProfilerEF.Initialize();
}
这篇关于首先为EF-db设置mvc-mini-profiler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!