public VetsRepo() { //Create DBContext and warm up data var dbContext = new VetsContext(new DbContextOptionsBuilder <VetsContext>().UseInMemoryDatabase("PetClinic_Vets").Options); dbContext.SeedAll(); Instance = new spring_petclinic_vets_api.Repository.Vets( new NullLogger <spring_petclinic_vets_api.Repository.Vets>(), dbContext ); }
public VetSpecialties(VetsContext dbContext) { _dbContext = dbContext; }
// 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, VetsContext 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 Vets Service"); }); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public Vets(VetsContext dbContext) { _dbContext = dbContext; }
// 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, VetsContext dbContext) { switch (Environment.EnvironmentName) { case ("Development"): case ("Docker"): logger.LogInformation($"Running as {Environment.EnvironmentName} environment"); app.UseDeveloperExceptionPage(); dbContext.SeedAll(); break; default: break; } ; //app.UseHttpsRedirection(); app.UseRouting(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Pet Clinic Vets Service"); }); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }