Junior EF Core

What is eager loading?

How is .Include() / .ThenInclude()

used?

Eager loading loads related data as part of the initial query, reducing round-trips to the

database.

✅ Use .Include() to load related entities:

var blogs = context.Blogs

.Include(b => b.Posts)

.ToList();

Use .ThenInclude() for deeper nesting:

context.Blogs

.Include(b => b.Posts)

.ThenInclude(p => p.Comments);

Eager loading prevents lazy load performance issues and the N+1 problem.

More from Entity Framework Core Tutorial

All questions for this course