public async Task <OkObjectResult> Index() { Person[] allPeople = new Person[0]; using (PrioritizeMeDbContext context = _factory.CreateDbContext(new string[0])) { allPeople = await context.People.ToArrayAsync(); } return(Ok(allPeople)); }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app">Injected <see cref="IApplicationBuilder"/></param> /// <param name="env">Injected <see cref="IHostingEnvironment"/></param> /// <param name="contextFactory">The application <see cref="IDesignTimeDbContextFactory{TContext}"/></param> public void Configure( IApplicationBuilder app, IHostingEnvironment env, IDesignTimeDbContextFactory <PrioritizeMeDbContext> contextFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); // Automatically migrate the application to the latest using (PrioritizeMeDbContext migrationContext = contextFactory.CreateDbContext(new string[0])) { migrationContext.Database.Migrate(); } } app.UseCors(MyAllowSpecificOrigins); app.UseHttpsRedirection(); app.UseMvc(); app.UseSwagger(c => { c.PreSerializeFilters.Add((swagger, httpReq) => swagger.Host = httpReq.Host.Value); }); app.UseSwaggerUI( c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); }); }