如何在mvc上使用级联引用删除,以便删除两个表?
public ActionResult Delete(int appointmentid)
{
Appointment appointment = _database.Appointment.Find(appointmentid);
if (appointment == null)
{
return HttpNotFound();
}
return View();
}
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int appointmentid)
{
Appointment appointment = _database.Appointment.Find(appointmentid);
if (appointment == null)
{
return HttpNotFound();
}
_database.Appointment.Remove(appointmentid);
_database.Appointment.SaveChanges();
return RedirectToAction("Create");
}
这不起作用