Miniprofiler 监控ef执行详解

首先NuGet添加 相对应ef版本的Miniprofiler.ef引用

 web.config文件中添加

<system.webServer>
<handlers> 
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>

Global 文件中添加

protected void Application_Start(object sender, EventArgs e)
{

StackExchange.Profiling.EntityFramework6.MiniProfilerEF6.Initialize();

}
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.IsLocal)
{
MiniProfiler.Start();
}
}
protected void Application_EndRequest(object sender, EventArgs e)
{
MiniProfiler.Stop();
}

在需要监控的webfrom页面中增加

protected override void OnPreRender(EventArgs e)
{
Response.Write(StackExchange.Profiling.MiniProfiler.RenderIncludes());
base.OnPreRender(e);
}

运行页面

 

点击share 查看详细信息

 

 

以上就是MiniProfiler 监控webfrom中使用ef操作过程。

 

转载于:https://www.cnblogs.com/farmer-y/p/5895352.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值