Click here to Skip to main content
15,887,930 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi experts,

i have big problems with cascading deletes in entityframework 6.
i have a simple database with just 2 tables, persons and addresses,
each Person can have 0 or many addresses -> 1:n relationship.
When i delete a person all addresses are also deleted -> GREAT!
But when i try to delete all addresses of a person i get an exception:
"The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted."

I have searched the Internet the last 2 days and the only thing i found that should work was to create a combined Primary key, but this also does not work for me.


Thanks
Manuel
Posted
Updated 24-Oct-14 2:43am
v2
Comments
Maciej Los 23-Oct-14 15:34pm    
Please, read the rules of posting questions on CP QA board. No one wants to download the code which can be suspicious. Instead of that post your code and the structure of your database.
m.bleimuth 24-Oct-14 8:43am    
sorry for that, i will remove the link
Maciej Los 24-Oct-14 8:50am    
Not to worry.
Cheers,
Maciej

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900