Friday, January 22, 2010 1:22 PM
I am using Entity Framework version 3 and I have read it includes a bug that prevents cascade delete from working correctly when the relationship is not one to many.
I have a Contact entity with a one to zero or one relationship to a ContactType entity. The relationship includes cascade delete. When I delete a contact without explicitly loading the ContactType, I get an EF exception saying the ContactType entity must also be deleted (which of course it should be automatically since cascade delete is on). Note I do have the same relationship defined (with cascade delete) in the database as well as in the SSDL and CSDL. If the related ContactType is loaded, then I do not have this exception and both records are removed correctly.
How can I ensure that when my client tier deletes a contact, the associated contact type will be silently deleted whether or not it is loaded in the data context?
Is there a best practice solution for this problem?
Wednesday, January 27, 2010 1:41 PMModeratorHello Carl
Could you please tell us what is the Entity Framework version 3? If you want to consult EF4 issues, please post the question at the EF pre-release forum here, http://social.msdn.microsoft.com/Forums/en-US/adonetefx/threads.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Thursday, January 28, 2010 1:07 PMI mean the EF that has been released for the past few years. Not EF4, but the version preceeding it.
Tuesday, March 02, 2010 1:25 PMHello Carl
Danny Simmos has a great workaround on this blog, http://blogs.msdn.com/dsimmons/archive/2010/02/06/cascade-delete-and-1-to-1-or-1-to-0-1-relationships.aspx.