// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext dbContext, IServiceProvider serviceProvider) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseGlobalExceptionMiddleware(); app.UseHttpsRedirection(); app.UseRouting(); app.UseOpenApi(); app.UseSwaggerUi3(); app.UseReDoc(configuration => configuration.Path = string.Empty); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHub <ServiceHub>("/ServiceHub"); }); DbContextExtensions.Seed(dbContext, serviceProvider); }
public static TodoAppContext GetTodoesDbContext(string dbName) { // Create options for DbContext instance var options = new DbContextOptionsBuilder <TodoAppContext>() .UseInMemoryDatabase(databaseName: dbName) .Options; // Create instance of DbContext var dbContext = new TodoAppContext(options); // Add entities in memory DbContextExtensions.Seed(dbContext); return(dbContext); }