[英]How to setup table per type inhertiance in entity framework when the derived table uses its own primary key?
Suppose I have a table structure such as: 假设我有一个表结构,例如:
Order
ID int, primary key
Name, string
OtherOrderFields...
RetailOrder
ID int, primary key
OrderID, foreign key
RetailOrderFields...
In entity framework 4, is it possible to set up table per type inheritance so that RetailOrder derives from Order? 在实体框架4中,是否可以为每个类型继承设置表,以便RetailOrder从Order派生? All the examples I've seen so far have the derived class using the foreign key (OrderID in this example) as the primary key for the table, but what if that's not the case and each table maintains its own primary key? 到目前为止,我所看到的所有示例都具有使用外键(在本示例中为OrderID)作为表主键的派生类,但是如果不是这种情况并且每个表都维护自己的主键怎么办?
No, it's impossible. 不,这是不可能的。 I think, your database schema guess aggregation (1-1 relation) instead of inheritance. 我认为,您的数据库架构猜测是聚合(1-1关系)而不是继承。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.