views:

239

answers:

1

Hi there,

I have an entity who's primary key is a foreign key in other tables in the database

In order to delete a record in this entity I need to first delete all the foreign keys records or the delete will not work

At the moment i have to select all the foeign key records manually and delete them which is a bit of a pain

Is there a way that you can tell the EF to delete all it's references in other tables automatically?

+2  A: 

EF does support cascaded deletes. You need to make sure that in the Association element of both the SSDL and CSDL include an OnDelete action for the appropriate end of the association. Once you set the OnDelete action, EF will enforce it for you.

jrista
Right (+1). You also need to have the cascade in your DB.
Craig Stuntz