EF4.5.1+MVC4
1、依次:Install-Package MiniProfiler,Install-Package MiniProfiler.EF5,Install-Package MiniProfiler.Mvc4
2.1、在_layout.cshtml 中加入
@using StackExchange.Profiling
<!DOCTYPE html>
..........
@MiniProfiler.RenderIncludes()
</body>
2.2、2.1中@using StackExchange.Profiling会在页面生成形如 <script async type="text/javascript" id="mini-profiler"......</script>的脚本,为了处理脚本,在web.config中加入:
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
不加这个,页面没有miniprofiler的显示。
3.1、在Global.asax中加入:
protected void Application_BeginRequest()
{
if (Request.IsLocal)
{
MiniProfiler.Start();
}
}
protected void Application_EndRequest()
{
MiniProfiler.Stop();
}
3.2 如果要看SQL的分析,要加入:
protected void Application_Start()
{
MiniProfilerEF.InitializeEF42();