Cascade Delete Fails on One to One Relationships RRS feed

  • Question

  • 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?


    Friday, January 22, 2010 1:22 PM

All replies