我引用了 MvcMiniProfiler 的 1.6 版(通过 Nuget),并按照项目主页http://code.google.com/p/mvc-mini-profiler/中的描述进行了所有设置。
我在 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>
(项目主页的 Version=1.5.0.0 - NuGet 包已经更新)
我在 Global.asax 中有以下代码(并且连接字符串也在 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 Express。我一直在关注 Google Code 项目主页上的相关问题,并且完全被卡住了。