Loading Related Data

Learn how to load related data via the navigational properties of entities in an EF Core model.

Overview

In this lesson, we’ll review strategies for loading related entities via the navigational properties of entities in EF Core. There are three common patterns:

  • Eager loading
  • Explicit loading
  • Lazy loading

The differences between these patterns are related to how and when EF Core translates the queries to the database.

Eager loading

Eager loading loads related data from the database as part of the initial query. It allows us to fetch related entities and prevent additional round-trips to the database. Eager loading uses the Include method to specify the related data.

We’ll demonstrate eager loading using the C# console project below:

Get hands-on with 1200+ tech skills courses.