Junior EF Core

What is lazy loading?

How to enable lazy loading in EF Core? What

are proxies?

Lazy loading delays the loading of related data until it's accessed for the first time.

EF Core requires proxies for lazy loading:

Install NuGet:

Microsoft.EntityFrameworkCore.Proxies

Enable in OnConfiguring or AddDbContext:

options.UseLazyLoadingProxies();

Mark navigation properties as virtual:

public virtual ICollection<Post> Posts { get; set; }

EF creates runtime proxies to override navigation properties and load them when

accessed.

More from Entity Framework Core Tutorial

All questions for this course