예제 #1
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            // DB migrations and Data seeding
            using (var scope = host.Services.CreateScope())
            {
                var serviceProvider = scope.ServiceProvider;

                var hostingEnv = serviceProvider.GetRequiredService <IWebHostEnvironment>();

                using (var context = serviceProvider.GetRequiredService <DfESurveyToolDbContext>())
                {
                    context.Database.Migrate();

                    await DataSeed.AddRequiredData(context);

                    if (hostingEnv.IsDevelopment())
                    {
                        await DataSeed.AddData(context);
                    }
                }
            }

            host.Run();
        }