// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); //Auth app.UseAuthorization(); app.UseAuthentication(); app.UseCors("AllowAngular"); //Swagger app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/" + version + "/swagger.json", "SantaPone Central " + version.ToUpper()); }); //Endpoints app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); // Ensures DB is created against container IServiceScopeFactory serviceScopeFactory = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>(); using IServiceScope serviceScope = serviceScopeFactory.CreateScope(); SantaPoneCentralDatabaseContext dbContext = serviceScope.ServiceProvider.GetService <SantaPoneCentralDatabaseContext>(); dbContext.Database.EnsureCreated(); }
public Repository(SantaPoneCentralDatabaseContext _context) { santaContext = _context ?? throw new ArgumentNullException(nameof(_context)); }