What is lazy loading proxy?
Short answer: How does the dynamic proxy work under the hood? EF Core creates a dynamic proxy subclass of your entity at runtime. Proxy overrides virtual navigation properties to load related data on-demand. Requires navigation properties to be virtual and package Microsoft.EntityFrameworkCore.Proxies. Proxy intercepts access and triggers loading when property is accessed.
Real-world example (ShopNest)
Loading orders with items uses .Include(o => o.Items). Without Include, listing 50 orders can trigger 50 extra queries (N+1).
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png