I recently updated a number of tables in the database to use OnDelete=Cascade
, however, when I went to update my edmx file via Update model from database
I noticed that the OnDelete
was not properly updated.
After a bit of searching, I found the following 'tip' from http://msdn.microsoft.com/en-us/library/bb738695.aspx
If you update the database with the cascade delete rule and then update the existing model from the database, the Entity Framework will add the cascade delete rule to the SSDL but 开发者_开发技巧not CSDL. You will have to add it manually. To specify the cascade delete rule in the conceptual model, select the association on the Entity Designer surface. Then, in the Properties window, select Cascade for the OnDelete property.
My question is why is this the case? I updated about 15 tables and now I need to go and find each relationship and do the same update in the edmx
file... Is there an easier more efficient way?
In a perfect world it should but apparently it is a known issue as they are baking it into the documentation. Creating, Adding, Modifying, and Deleting Objects
It's in the tip block just before the In this Section part.
So unless the Designer programmer who coded it wants to explain it, we'll have to accept the 'working as intended' thing.
精彩评论