Пример #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Access-Control-Allow-Origin
            app.UseCors("AllowAll");

            // Enable authentication middleware
            app.UseAuthentication();

            // Add MVC
            app.UseMvc();

            //Swagger Configure
            app.UseSwaggerConfigure();

            // Database Intilization
            var optionsBuilder = new DbContextOptionsBuilder <FastFoodDbContext>();

            optionsBuilder.UseSqlite(Configuration.GetConnectionString("Default"));

            using (var context = new FastFoodDbContext(optionsBuilder.Options))
            {
                Console.WriteLine("Database Migration started...");
                context.InitializeDatabase();
                Console.WriteLine("Database Migrated and Seeded...");
            }
        }