Created
April 20, 2019 09:55
-
-
Save Diaskhan/cb5544d0557c6001d1c4c6ac2b656c98 to your computer and use it in GitHub Desktop.
dbcontext lambda
This file contains hidden or 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
rowanmiller commented on 31 Jul 2015 | |
@sonofsam I think rather than putting the ModelBuilder in DI you want to construct your model and set it on the DbContextOptions that are registered in DI. | |
var builder = new ModelBuilder(); | |
// all the code to configure your model | |
var model = builder.Model; | |
services.AddEntityFramework() | |
.AddSqlServer() | |
.AddDbContext<MyDbContext>(options => | |
{ | |
options.UseSqlServer("<connection string>"); | |
options.UseModel(model); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment