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 <AppDbContext>(); context.Database.Migrate(); await AppDbContextSeed.SeedSampleProductsAsync(context); } catch (Exception ex) { // _logger.LogError("Error occured on main: {ex}", ex); } } await host.RunAsync(); }