/AppServices.cs Secret
Last active
February 14, 2019 08:03
Star
You must be signed in to star a gist
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