One-to-Many Cascading Deletions

I have [Product] -1 - * - [Component]. Therefore, when I delete a product, I want EF to remove all its components. In the designer, I select the relation and set the OnDelete property for End1 in Cascade, whose multiplicity is 0..1 - this generates something like:

ALTER TABLE [dbo].[Components]
ADD CONSTRAINT [FK_ProductComponent]
    FOREIGN KEY ([Product_Id])
    REFERENCES [dbo].[Products]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;

which for me means that when a component is removed, the removal must be cascaded, and the product associated with it should also be automatically deleted.

This is back from what I wanted. So I edited the property for End2 to Cascade (End1 gets reset to None), but when I try to save the model, I get:

Error   28  Running transformation: End 'Text' on relationship 
'EF.ProductComponent' cannot have operation specified since its multiplicity 
is '*'. Operations cannot be specified on ends with multiplicity '*'.   C:\Users
\me\Documents\Visual Studio 2010\Projects\X\Website\Models\EF.edmx
I do not understand this. Can I do what I want, no? as?
+3
source share

All Articles