-
-
Save christiannagel/b58bc5dd387304532dae127839380178 to your computer and use it in GitHub Desktop.
EF Core DbContext configuration with lazy loading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ServiceProvider GetServiceProvider() => | |
new ServiceCollection() | |
.AddLogging(config => | |
{ | |
config.AddConsole() | |
.AddDebug() | |
.AddFilter(level => level > LogLevel.Debug); | |
}) | |
.AddTransient<BooksService>() | |
.AddDbContext<BooksContext>(options => | |
{ | |
options.UseLazyLoadingProxies() | |
.UseSqlServer(Configuration.GetConnectionString(BooksConnection)); | |
}) | |
.BuildServiceProvider(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment