EntityFramework - Delete Many to Many relationship
I have the following entity tree:
Also there is a many to many relationship (mapped to a FK-FK table) between ParameterOperation and Parameter. All associations are declared as Delete cascade (only the many to many is not Delete cascade). The thing is that when I MarkAsDeleted Parameter Object through ParameterOperation (ParameterDefinition.ParameterOperations.Parameters.MarkAsDeleted) it is deleted from DB and the map table is updated as well (row is deleted), but when I try to delete Parameter From ParameterGroup (ParameterDefinition.ParameterGroups.Parameters.MarkAsDeleted) it is not deleted at all (no delete query is executed on DB). What might be the problem?
Also how do i delete a many to many relationship? for example I want to keep all Parameters and all ParameterOperations but I want to delete the relationship between Parameters and ParameterOperations.
How can I do it?
if I set the NavigationProperty - ParameterDefinition.ParameterOperations.Parameters.MarkAsDeleted it actually deleted the Parameter from DB what I don't want
Simply removing the Parameter Entity from the ParameterOperation's collection, and then saving your context should be enough to delete the many to many relationship that exists in the junction table.