使用实体框架中的单个表建立一对多关系模型
假设我的物理模型上有 2 个表,Receipt(ID, Location) 和 LineItem(ID, ReceiptID, ItemName),其中收据有多个 LineItem,ReceiptID 是收据 ID 的外键。
我想在我的概念模型中将它们建模为单个表,其中我只看到一个 LineItems 表,其中每个 LineItem 上都包含位置。
每次我尝试在实体建模器中对其进行建模时,都会收到一条错误消息,提示对于组合成单个概念实体的每个表,主键必须相同。
这是否可以使用实体框架进行建模?
谢谢!
Lets say I have 2 tables on my physical model, Receipt(ID, Location) and LineItem(ID, ReceiptID, ItemName) where a Receipt has multiple LineItems and ReceiptID is a Foreign Key to Receipt's ID.
I want to model these as a single table in my conceptual model, where I only see a table of LineItems with the Location included on each LineItem.
Every time I try to model this in the Entity Modeler, I get an error about how the Primary Key must be the same for every table being combined into the single conceptual entity.
Is this even possible to model using the entity framework?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,没有办法直接对此进行建模。您必须创建数据库视图并映射该视图,或者导入两个实体并创建 QueryView 在模型中。在这两种情况下,组合两个表的结果实体将变为只读,并且支持 CUD 操作的唯一方法是映射存储过程。
No there is no way to model this directly. You must either create database view and map that view or import both entities and create QueryView in the model. In both cases resulting entity combining your two tables will become readonly and the only way to support CUD operations will be mapping stored procedures.