public IActionResult DeleteTest(int id) { Tests test = db.Set <Tests>().SingleOrDefault(c => c.TestId == id); if (test != null) { db.Entry(test).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; db.SaveChanges(); } return(RedirectToAction("TestList")); }