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

            using (var scope = host.Services.CreateScope())
            {
                var services    = scope.ServiceProvider;
                var dataContext = services.GetRequiredService <DataContext>();
                DataContextSeed.Seed(dataContext);
            }
            host.Run();
        }
예제 #2
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services      = scope.ServiceProvider;
                var loggerFactory = services.GetRequiredService <ILoggerFactory>();
                try
                {
                    var dataContext = services.GetRequiredService <DataContext>();
                    DataContextSeed.Seed(dataContext, loggerFactory);
                }
                catch (Exception ex)
                {
                    var logger = loggerFactory.CreateLogger <Program>();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }

            host.Run();
        }
예제 #3
0
        public static void Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services           = scope.ServiceProvider;
                var loggerFactory      = services.GetRequiredService <ILoggerFactory>();
                var unitOfWork         = services.GetRequiredService <IUnitOfWork>();
                var appointmentService = services.GetRequiredService <AppointmentsService>();
                var patientsService    = services.GetRequiredService <PatientsService>();
                try
                {
                    DataContextSeed.Seed(patientsService, appointmentService, loggerFactory);
                }
                catch (Exception ex)
                {
                    var logger = loggerFactory.CreateLogger <Program>();
                    logger.LogError(ex, "An error occured during migration");
                }
                host.Run();
            }
        }