public async static Task Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <ApplicationDbContext>(); var userManager = services.GetRequiredService <UserManager <ApplicationUser> >(); await context.Database.EnsureCreatedAsync(); await ApplicationDbContextSeed.SeedDefaultUsersAsync(userManager); await ApplicationDbContextSeed.SeedSampleDataAsync(context); } catch (Exception ex) { var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the cosmos db."); throw; } } await host.RunAsync(); }