public static void Main(string[] args) { var host = CreateHostBuilder(args) .ConfigureAppConfiguration((hostContext, builder) => { if (hostContext.HostingEnvironment.IsDevelopment()) { builder.AddUserSecrets <Program>( ); } }) .Build( ); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { AppDbSeed.SeedSampleData(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >( ); logger.LogError(ex, "Error while seeding the db."); } } host.Run(); }
public static void Main(string[] args) { var host = CreateHostBuilder(args).Build( ); using (var scope = host.Services.CreateScope( )) { var services = scope.ServiceProvider; try { AppDbSeed.SeedSampleData(services); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >( ); logger.LogError(ex, "Error while seeding the db."); } } host.Run( ); }