title: Delete an object with a many to many relationship from the entities framework?
body: <p>I have two objects (class, student) in a database with a many to many relationship (using a simple junction table). I've figured out how to correctly add new objects to tables, and now I'd like to delete an object.</p>
  
  <p>I've been trying the following:</p>
  
  <pre><code>// (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();
  </code></pre>
  
  <p>Which gives the error:</p>
  
  <pre><code>"The DELETE statement conflicted with the REFERENCE constraint \"FK_JunctionClassObjsStudents_Students\".
  </code></pre>
  
  <p>Where JunctionClassObjsStudents is the name of the junction table which creates the many to many relationship between classes and students tables.</p>
  
  <p>What do I need to do? Thanks for your help!! </p>