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>(); await ApplicationDbContextSeed.SeedAsync(context); var userManager = services.GetRequiredService <UserManager <ApplicationUser> >(); var roleManager = services.GetRequiredService <RoleManager <IdentityRole> >(); await ApplicationDbContextSeed.SeedUserAsync(userManager, roleManager); } catch (Exception ex) { ex.ToString(); } } host.Run(); }