// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicaitonDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); // Create or update the database and apply migrations. context.Database.Migrate(); // Add a book and review or two as sample/test data. SeedData.Seed(context); }
//using dependency injeciton public CreateModel(ApplicaitonDbContext db) { _db = db; }
public Repository(ApplicaitonDbContext appDbContext) { context = appDbContext; }
//using dependency injeciton public IndexModel(ApplicaitonDbContext db) { _db = db; }