public static void Main(string[] args) { var host = CreateHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <DataContext>(); var userManager = services.GetRequiredService <UserManager <AppUser> >(); context.Database.MigrateAsync(); Seed.DbSeed(context, userManager); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occured during migration"); } } host.Run(); }