Sunday, November 16, 2025

EF - Lazy Vs Eager loading

What is Lazy Loading?

Lazy loading loads related data automatically when it's accessed, not when the main entity is loaded. It can cause multiple SQL queries.

What is Eager Loading?

Eager loading loads all required related data in a single query using .Include(), improving performance in most web applications.

When should you avoid lazy loading?

Avoid lazy loading in Web APIs because it can produce many unnecessary queries and severely impact performance.

 



No comments:

Post a Comment

CI/CD - Safe DB Changes/Migrations

Safe DB Migrations means updating your database schema without breaking the running application and without downtime . In real systems (A...