Created
January 26, 2022 17:09
-
-
Save solrevdev/1b8326a9acc05eea6ef335a33a293dbb to your computer and use it in GitHub Desktop.
Seed data using minimal api
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
if (args.Length == 1 && args[0].ToLower() == "seeddata") | |
{ | |
SeedData(app); | |
} | |
void SeedData(IHost app) | |
{ | |
var scopedFactory = app.Services.GetService<IServiceScopeFactory>(); | |
using (var scope = scopedFactory.CreateScope()) | |
{ | |
var service = scope.ServiceProvider.GetService<DataSeeder>(); | |
service.Seed(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment