public static void SeedTestData(this IApplicationBuilder app) { using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { DataSeed.EnsureSeedData(scope.ServiceProvider).ConfigureAwait(false).GetAwaiter().GetResult(); } }
public static async Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.GetRequiredService <IServiceScopeFactory>().CreateScope()) { await DataSeed.EnsureSeedData(scope.ServiceProvider); } host.Run(); }