public ActionResult Update(Person person) { using(var db = new PersonContext()) { db.Persons.Attach(person); db.Entry(person).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } }
public ActionResult Delete(int id) { using(var db = new PersonContext()) { var p = db.Persons.Find(id); db.Entry(p).State = EntityState.Deleted; db.SaveChanges(); return RedirectToAction("Index"); } }