This is my code:
Student student = db.Students.Find(id);
db.Students.Remove(student)
db.SaveChanges();
return RedirectToAction("Index");
I get the following error
SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK_Payment_Student". The conflict occurred in database "BlackBeardDB", table "dbo.Payment", column 'studentID'
The code is not deleting the record. Do I have to use CascadeOnDelete();
for this?