简体   繁体   中英

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?

In case it matters, we're using EF6, but the context is based on ObjectContext instead of 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. You can see how the querys are been translated, and what time each query takes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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