Skip to content

Instantly share code, notes, and snippets.

@maltegoetz
Created May 21, 2019 21:10
Show Gist options
  • Save maltegoetz/dea243b3fca01c841326692977fb85d5 to your computer and use it in GitHub Desktop.
Save maltegoetz/dea243b3fca01c841326692977fb85d5 to your computer and use it in GitHub Desktop.
EF Core Enable Lazy Loading
//You can either override OnConfiguring in DbContext:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseLazyLoadingProxies()
.UseSqlServer(myConnectionString);
//...or if you are using ASP.NET and AddDbContext:
.AddDbContext<PizzaContext>(
b => b.UseLazyLoadingProxies()
.UseSqlServer(myConnectionString));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment