简体   繁体   English

在实体框架中检测延迟加载

[英]Detect lazy loading in Entity Framework

I've been tasked with speeding up a giant codebase. 我的任务是加速庞大的代码库。 One of the things I have noticed is that the team uses lazy loading everywhere. 我注意到的一件事是,团队在所有地方都使用了延迟加载。 So much so that I think there's a lot to be gained by disabling it. 如此之多以至于我认为禁用它可以带来很多好处。 There would be too much of an impact if I disabled it entirely so I'd rather do this in phases. 如果我完全禁用它,将会产生太大的影响,所以我宁愿分阶段进行。

This got me thinking: is there a way (an event?) to detect when EF is doing something lazily? 这让我开始思考:是否有一种方法(一个事件?)来检测EF何时懒惰地做某事?

In case it matters, we're using EF6, but the context is based on ObjectContext instead of DbContext . 如果很重要,我们将使用EF6,但是上下文基于ObjectContext而不是DbContext

Due to the mess of the codebase it's not an option to just find references on the navigation properties. 由于代码库混乱,所以不能仅在导航属性上查找引用。

I recommend you to use Glimpse , its a powerful tool for so many things, including EF profiler. 我建议您使用Glimpse ,它是用于包括EF分析器在内的许多功能的强大工具。 You can see how the querys are been translated, and what time each query takes. 您可以查看查询的翻译方式以及每个查询的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM