How does WillCascadeOnDelete in Entity Framework work?

断了今生、忘了曾经 提交于 2019-11-30 11:18:45

This is because your foreign keys (child) are nullable. By default, when deleting parent, if the foreign key on the relationship is nullable EF will delete the parent and set the foreign key to null. If the foreign key is NOT NULL it will delete the child (the behaviour you're looking for?).

You can alter this default behaviour here

Make sure on the Foreign Key Relationship window in SQL Server, you have selected Cascade as Delete rule.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!