如何拆分扩展实体 [英] How to splitting an extended entity
问题描述
我想拆分扩展实体。
原始实体是Employee,具有以下属性:EmployeeID,即实体的主键,FirstName,LastName,Wage,Salary。
扩展实体是ExtendedEmployee,其属性包括:EmployeeID(外键)和电子邮件。
在edmx中,两者都是实体合并为一个实体。我想将此实体拆分为另外两个实体,PartTimer和FullTimer。但是,edmx中不允许这样做。尝试验证时出现以下错误:
[ 错误 ]
问题 从行开始的映射片段 90 : 必须 指定所有关键属性的映射 ( 员工 。 EmployeeID ) 表 员工 。
问题 映射片段从行开始 85 :跨度> <跨度class ="typ">必须 指定所有关键属性的映射 ( 员工 。 EmployeeID ) 表 员工 。
问题 mapping从行开始的片段 90 : 必须 指定所有关键属性的映射 ( 员工 。 EmployeeID ) EntitySetEmployees 。
问题 映射片段从行开始 85 : 必须 指定所有关键属性的映射 ( 员工 。 EmployeeID ) EntitySetEmployees 。
在这里我附上参考项目,万一有人想看看。任何帮助都是
$
非常感谢。谢谢!
附件
安德鲁,
你可以"拆分"一个实体使用
partial class 。
您应该能够通过创建名为Employee.PartTimer.cs的新(部分)类来实现此目的(例如)。通过使其与原始实体相同来编辑其命名空间。之后,您应该可以添加新的自定义属性。
这是否可以回答您的问题?
希望这会有所帮助!
I want to split an extended entity.
The original entity is Employee, that has the following propery: EmployeeID that is Primary Key of the entity, FirstName, LastName, Wage, Salary.
The extended entity is ExtendedEmployee that has properties such as : EmployeeID (foreign key) and Email.
In the edmx, both entity is combined into one entity. I want to split this entity into two other entities, PartTimer and FullTimer. However, this is not allowed in edmx. I got the following error when trying to validate:
[Error] Problem in mapping fragments starting at line 90:Must specify mappingfor all key properties (Employee.EmployeeID) of table Employee. Problem in mapping fragments starting at line 85:Must specify mappingfor all key properties (Employee.EmployeeID) of table Employee. Problem in mapping fragments starting at line 90:Must specify mappingfor all key properties (Employees.EmployeeID) of the EntitySetEmployees. Problem in mapping fragments starting at line 85:Must specify mappingfor all key properties (Employees.EmployeeID) of the EntitySetEmployees.
Here I attach the reference project, in case anyone wants to take a look. Any help is
greatly appreciated. Thanks!
Hi Andrew,
You can "split" one entity by using partial classes.
You should be able to accomplish this by creating a new (partial) class named Employee.PartTimer.cs (for example). Edit its namespace, by making it the same as the original Entity. Afterwards, you should be able to add new custom properties.
Does this answer your question?
Hope this helps!
这篇关于如何拆分扩展实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!