public async Task <IActionResult> Index() { var optionsBuilder = new DbContextOptionsBuilder <BookPurchaseContext>(); var options = optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=WitcherShop;Trusted_Connection=True;") .Options; BookPurchaseContext context = new BookPurchaseContext(options); Book book = context.books.Where(b => b.id == 8).FirstOrDefault(); context.books.Remove(book); context.SaveChanges(); return(View(await db.books.ToListAsync())); }
public HomeController(BookPurchaseContext context) { db = context; }