Пример #1
0
        static void Main(string[] args)
        {
            var builder = new DbContextOptionsBuilder <FlightInfoDbContext>();
            FlightInfoDbContext context = new FlightInfoDbContext(builder.Options);

            FlightInfoInitializer.Initialize(context);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                try
                {
                    var context = scope.ServiceProvider.GetService <FlightInfoDbContext>();
                    //context.Database.Migrate();

                    FlightInfoInitializer.Initialize(context);
                }
                catch (Exception ex)
                {
                    var logger = scope.ServiceProvider.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred while migrating or initializing the database.");
                }
            }

            host.Run();
        }