[英]Entity Framework Model Multiple Table to Single Entity
I've two tables named Modules and Privileges which are related by a foreign key relationship as shown below:我有两个名为 Modules 和 Privileges 的表,它们通过外键关系相关联,如下所示:
(source: baburajpb at sites.google.com ) (来源: baburajpb 在sites.google.com )
I'd like to model Module and Privilege by adding ModuleName to Privilege.我想通过将 ModuleName 添加到 Privilege 来对 Module 和 Privilege 进行建模。 Later I'd be interested in creating a derived class (Menu in the illustration) from Privilege by adding a discriminating condition on ModuleName.后来我对通过在 ModuleName 上添加区分条件从 Privilege 创建派生类(图中的 Menu)感兴趣。 Is this possible using Entity Framework?这可以使用实体框架吗?
Can you map multiple tables to a single entity type?您可以将多个表映射到单个实体类型吗? Sure, that is supported. 当然,这是支持的。 However, you cannot use a mapped field of the table (ModuleName) as a discriminator column for table per hierarchy mapping.但是,您不能使用表的映射字段 (ModuleName) 作为每个层次映射表的鉴别器列。 The discriminator column must be used as a discriminator alone, and must not be mapped into your client schema.鉴别器列必须单独用作鉴别器,不得映射到您的客户端架构中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.