// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger, VisitsContext dbContext) { switch (Environment.EnvironmentName) { case ("Development"): case ("Docker"): logger.LogInformation($"Running as {Environment.EnvironmentName} environment"); app.UseDeveloperExceptionPage(); break; default: break; } ; dbContext.SeedAll(); //app.UseHttpsRedirection(); app.UseRouting(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Pet Clinic Visits Service"); }); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger, VisitsContext dbContext) { logger.LogInformation($"Running as {env.EnvironmentName} environment"); switch (env.EnvironmentName.ToLower()) { case ("development"): case ("docker"): app.UseDeveloperExceptionPage(); break; default: break; } ; // if using MySql, the tables should be creating using SQL scripts instead of using EF db-first dbContext.SeedAll(ensureCreated: !Configuration.GetValue <bool>("UseMySql")); app.UseRouting(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Pet Clinic Visits Service"); }); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public VisitsRepo() { //Create DBContext and warm up data var dbContext = new VisitsContext(new DbContextOptionsBuilder <VisitsContext>().UseInMemoryDatabase("PetClinic_Visits").Options); dbContext.SeedAll(); Instance = new spring_petclinic_visits_api.Repository.Visits( new NullLogger <spring_petclinic_visits_api.Repository.Visits>(), dbContext ); }