// 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()) { // FakeDB.InitDataPet(); using (var scope = app.ApplicationServices.CreateScope()) { var ctx = scope.ServiceProvider.GetRequiredService <PetShopContext>(); ctx.Database.EnsureDeleted(); ctx.Database.EnsureCreated(); _db.SeedDb(ctx); } app.UseDeveloperExceptionPage(); } else { using (var scope = app.ApplicationServices.CreateScope()) { var ctx = scope.ServiceProvider.GetRequiredService <PetShopContext>(); ctx.Database.EnsureCreated(); if (ctx.Pets.Any()) { _db.SeedDb(ctx); } } app.UseHsts(); } //app.UseHttpsRedirection(); app.UseAuthentication(); app.UseMvc(); }