I am trying to delete an object that sometimes has a many-to-many relation. The code I use now is:
db.DeleteObject(registeredDevice);
db.SaveChanges();
This ofcourse just removes the registeredDevice. But usually this device has a many-to-many relation to a project in the database. When trying to delete the device in that scenario it will give an error.
The DELETE statement conflicted with the REFERENCE constraint
What I need to do is remove the device and its relation (the entry in the many-to-many table, not the project it is related to). How do In do this with LINQ ?