// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); c.RoutePrefix = string.Empty; }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseCors("CorsPolicy"); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); DatabaseSeeder.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider); DatabaseSeeder.CreateRoles(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider, Configuration).Wait(); DatabaseSeeder.AssigneRoles(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider).Wait(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }