I have two objects (class, student) in a database with many for many relationships (using a simple join table). I figured out how to correctly add new objects to tables, and now I would like to delete the object.
I tried the following:
// (a classobj with id==1 does exist)
ClassObj cl = (from c in entities.ClassObjs where c.ClassID == 1 select c).First();
entities.ClassObjs.DeleteObject(cl);
entities.SaveChanges();
Which gives an error:
"The DELETE statement conflicted with the REFERENCE constraint \"FK_JunctionClassObjsStudents_Students\".
Where JunctionClassObjsStudents is the name of the join table that creates the relationship between many and many relationships between classes and student tables.
What do I need to do? Thank you for your help!!
source
share