Eager loading
An entity in Entity Framework Core can be associated with other entities in a number of ways:
One-to-one relationship: Where two entities share a primary key
One-to-many: An entity has a collection of entities
Many-to-one: The inverse of one-to-many; an entity has a pointer to another entity
When querying for an entity, Entity Framework does not automatically bring the entities associated with it. This is actually a good thing: depending on how closely related the entities are, asking for one entity could bring with it the entire database!
This doesn't mean, of course, that we can't retrieve, on the same query, all the associated entities that we're interested in: this is called eager loading. In fact, in Entity Framework Core 1, this is of particular importance, since lazy loading is not yet implemented.
Note
The SELECT N+1
problem is not relevant for Entity Framework Core, since it doesn't (yet) have lazy loading.
Getting ready
We will be using the NuGet Package Manager to install...