public static async Task Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var dbContext = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); ApplicationDbContextSeed.SeedProductsAndCategories(dbContext); var userManager = scope.ServiceProvider.GetRequiredService <UserManager <ApplicationUser> >(); var roleManager = scope.ServiceProvider.GetRequiredService <RoleManager <IdentityRole> >(); await ApplicationDbContextSeed.SeedUsersandRolesAsync(userManager, roleManager); } host.Run(); }