如何停止“级联删除”免遭实体框架默默删除?

发布于 2024-12-09 03:15:29 字数 373 浏览 0 评论 0原文

我的数据库中有一个级联删除集。我还为我的EDMX模型中的对应关系设置了级联删除。

但是,如果我从 EDMX 中删除具有关系的表,然后通过“从数据库更新模型”将它们添加回来 - 级联已被删除。

Craig Stuntz 提出相关问题表明这是一个功能,但是如果每次我更新模型时我的级联都会被悄悄删除 - 这是行不通的。

也许我需要更改我的工作流程,而不是删除并重新添加 EDMX 中的表,而只是手动进行所有小的单独列更改?

I have a cascade delete set in my database. I have also set a cascade delete for the corresponding relationship in my EDMX model.

However if I delete the tables with the relationship from the EDMX and then add them back in through "Update Model From Database" - the cascade has been removed.

Craig Stuntz in a related question suggests that it is a feature, however if my cascades are being silently removed each time I do an update of the model - that's unworkable.

Perhaps I need to change my workflow and not delete and re-add tables in the EDMX, rather just make all the little individual column changes by hand?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苍景流年 2024-12-16 03:15:29

如果您从模型中删除任何内容,您也会删除所有更改。您的更改已消失,EDMX 不再了解它们。再次添加表后,您还必须再次进行所有更改。

如果您想保留更改,请不要删除实体,而是直接运行向导。它应该只更新现有实体而不删除大部分更改。我只知道这不起作用并且您的更改丢失并且与重命名某些导航属性相关的单个示例。

If you delete anything from your model you also delete all your changes. Your changes are gone and EDMX doesn't know about them any more. Once you add tables again you must do all your changes again as well.

If you want to keep your changes don't delete your entities and instead run wizard directly. It should just update existing entities without removing most of your changes. I'm aware only about single example where this doesn't work and your changes are lost and that relates to renaming some navigation properties.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文