MvcMiniProfiler在EF 4.1 code-第一个项目没有轮廓SQL [英] MvcMiniProfiler on EF 4.1 Code-First project doesn't profile SQL

查看:115
本文介绍了MvcMiniProfiler在EF 4.1 code-第一个项目没有轮廓SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有(通过的NuGet)引用的MvcMiniProfiler的1.6版本,并根据在的 HTTP://$c$c.google.com/p/mvc-mini-profiler/

I have version 1.6 of the MvcMiniProfiler referenced (via Nuget) and have set everything up as described on the project homepage at http://code.google.com/p/mvc-mini-profiler/.

我在Web.config以下code:

I have the following code in the Web.config:

<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, Version=1.6.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3" />
    </DbProviderFactories>
</system.data>

(该项目主页有版本= 1.5.0.0 - 在包的NuGet已经被更新)

(The project homepage has Version=1.5.0.0 - the NuGet package has since been updated)

我在Global.asax以下code(和连接字符串在Web.config中定义):

I have the following code in the Global.asax (and connection string also defined in Web.config):

    protected void Application_Start()
    {
        Log.Info("ReCoupon has started.");

        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);

        var factory = new SqlConnectionFactory(ConfigurationManager.ConnectionStrings["ReCouponContext"].ConnectionString);
        var profiled = new MvcMiniProfiler.Data.ProfiledDbConnectionFactory(factory);
        Database.DefaultConnectionFactory = profiled;

        Database.SetInitializer(new ReCouponContextInitializer());
    }

探查工作,只是我不能让它来分析SQL很大。我使用SQL Server 2008前preSS。我一直在关注的谷歌code项目主页相关的问题和我完全卡住。

The profiler works great except that I can't get it to profile SQL. I am using SQL Server 2008 Express. I've been following the related issues on the Google Code project homepage and am totally stuck.

推荐答案

此一人难住了我很长一段时间了。看来,在连接字符串命名约定需要precedence超过Database.DefaultConnectionFactory。

This one had me stumped for a long time too. It appears that the connection string naming convention takes precedence over Database.DefaultConnectionFactory.

你能尝试重命名在web.config中的连接字符串?

Could you try renaming the connection string in the web.config?

   <connectionStrings>
       <add name="ReCouponContext" connectionString="..." />
   </connectionStrings>

   <connectionStrings>
       <add name="ReCoupon" connectionString="..." />
   </connectionStrings>

,然后更改

var factory = new SqlConnectionFactory(ConfigurationManager.ConnectionStrings["ReCouponContext"].ConnectionString);

var factory = new SqlConnectionFactory(ConfigurationManager.ConnectionStrings["ReCoupon"].ConnectionString);

这篇关于MvcMiniProfiler在EF 4.1 code-第一个项目没有轮廓SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆