Entity Framework: Can you cascade deletes?
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 automat开发者_开发技巧ically?
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.
精彩评论