예제 #1
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var context = services.GetRequiredService <Context>();
                    PeopleSeeder.Seed(context);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while seeding the database.");
                }
            }

            host.Run();
        }
예제 #2
0
 private void SeedCustomersTable()
 {
     using (var dbCtx = DbContextProvider.CreateDbContext())
         PeopleSeeder.Seed(dbCtx);
 }