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

            using (var scope = host.Services.CreateScope()){
                var services = scope.ServiceProvider;

                try{
                    Seeds.Initialize(services);
                }
                catch (Exception exception) {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(exception, "The DB Could not be seeded");
                }
            }

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

            using (var scope = host.Services.CreateScope())
                try
                {
                    var dbContxet = scope.ServiceProvider.GetService <WorkDbContext>();
                    Seeds.Initialize(dbContxet);
                }
                catch (Exception e)
                {
                    var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >();
                    logger.LogError(e, "Database Migration Error!");
                }

            host.Run();
        }
Example #3
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                var context = services.GetRequiredService <AirportContext>();

                context.Database.Migrate();
                Seeds.Initialize(services);

                host.Run();
            }



            //            BuildWebHost(args).Run();
        }