开发者

Entity Framework - Cascade Delete not getting set in Entity Model

开发者 https://www.devze.com 2023-01-14 09:54 出处:网络
I am using EF 4.0 and am开发者_如何学运维 generating my Entity Model (.edmx) file from my database. I have several foreign key constraints for Cascade OnDelete, however, these are not getting set on m

I am using EF 4.0 and am开发者_如何学运维 generating my Entity Model (.edmx) file from my database. I have several foreign key constraints for Cascade OnDelete, however, these are not getting set on my associations in my entity model. I click on the association and it shows End1 OnDelete: None.

When I check the Delete rules in my SQL Server 2008 database on my foreign key constraint, it says 'Cascade'.

Is there something I am missing to get the Cascade OnDelete flag to set in my entity model?


This answer

"I was having the same problem with SQL Server. When I tried to update mode from database, it didn't pick up the cascade rules. Note that the rules were added after the model was already created. I even tried deleting a table from the model and adding it back in. That had the same effect - no cascade rules.

However, when I created a brand new model with the same exact tables, it picked up the cascade rules. So my solution was just to delete the old model and create a new one with the same name, etc.

I guess is that there is something wrong with the update model from database process."

from this thread worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号