public void Configure(IApplicationBuilder app, IHostingEnvironment env, CRUDAppContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); context.Database.Migrate(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Team}/{action=Index}/{id?}"); }); }
public async Task Invoke(HttpContext httpContext) { using (var serviceScope = httpContext.RequestServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { using (CRUDAppContext crudAppContext = serviceScope.ServiceProvider.GetService <CRUDAppContext>()) { crudAppContext.Database.Migrate(); } } await _next(httpContext); // calling next middleware }
public InternsController(CRUDAppContext context) { _context = context; }
public DepartmentsController(CRUDAppContext context) { _context = context; }