示例#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, AirportContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseMvc();

            AirportDbInitializer.Initialize(context).Wait();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, AirportContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors("MyPolicy");
            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseMvc();


            AirportDbInitializer.Initialize(context).Wait();
        }
示例#3
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();
            }

            app.UseCors(builder => builder.WithOrigins("http://localhost:4200").AllowCredentials().AllowAnyHeader()
                        .AllowAnyMethod());

            using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                var context = scope.ServiceProvider.GetService <AirportContext>();
                context.Database.EnsureCreated();
                AirportDbInitializer.Initialize(context);
            }

            app.UseMvc();
        }
示例#4
0
 public AirportContext(DbContextOptions <AirportContext> options)
     : base(options)
 {
     AirportDbInitializer.Initialize(this); //Seed db
 }
 public async Task DropDB()
 {
     await AirportDbInitializer.Drop(_airportContext);
 }
 public async Task SeedDB()
 {
     await AirportDbInitializer.Initialize(_airportContext);
 }
 public void DropDB()
 {
     AirportDbInitializer.Drop(_airportContext);
 }
 public void SeedDB()
 {
     AirportDbInitializer.Initialize(_airportContext);
 }