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[0].Parameters[0].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[0].Parameters[0].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[0] and ParameterOperations[0].

How can I do it?

if I set the NavigationProperty - ParameterDefinition.ParameterOperations[0].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.


Need Your Help

jPlayer is not a function error - Stream Player

jquery-plugins jplayer

Sorry for asking this question as it may be asked some times around the internet, but none of the proposed sollutions worked on my site.

How to replace \\n by \n in Java


I have a string test="first \\n middle \\n last"