让两个不同实体引用一个表是一种好的做法吗?

发布于 2024-08-08 02:31:27 字数 307 浏览 5 评论 0原文

我正在使用以下模式构建应用程序:Silverlight、RIA、EF、Prism、SL 单元测试。

该项目将有许多实体和引用这些实体的许多模块。每个实体以及 RIA 域服务和关联元数据都位于其自己的 RIA 服务库中。

当我在两个不同的实体中引用某个表时,我遇到了问题。例如表栏存在于实体1和实体2中。

我的问题:在多个实体(.edmx 文件)中使用同一个表是否是一种好的做法?

如果是这样,有什么好方法可以避免它们导致多重引用错误?

如果不是,当我需要另一个实体中的该表时该怎么办?

I am building a application with these patterns: Silverlight, RIA, EF, Prism, SL Unit Testing.

This project will have lots of entities and lots of modules referencing those entities. Each entity is in its own RIA Service Library along with the RIA domain service and associated metadata.

I am running into problems when I reference a certain table in two different entities. For example table bar exists in entity1 and entity2.

My Question: Is it good practice to have the same table in multiple entities (.edmx files)?

If so what are good ways to avoid them causing a mulitple reference error?

If not what do I do when I need that table in another entity?

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

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

发布评论

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

评论(1

短暂陪伴 2024-08-15 02:31:27

通常,当您开始使用 EF(以及大多数 ORM)时,如果您的实体具有继承性,您倾向于建立实体与表的关系,或者至少是表->实体层次结构关系。

如果您尝试从两个单独的实体类型引用同一个表,则可能需要提取由两个其他实体引用的共享的单个实体类型。

Normally, when you start working with EF (and most ORMs), you tend towards having an entity-per-table relationship, or at least, a table->entity hierarchy relationship, if you have inheritance in your entities.

If you're trying to refer to the same table from 2 separate entity types, you probably need to pull out a shared, single entity type that's refered to by both of your other entities.

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