我从数据库创建了一个实体模型,并收到错误“成员名称不能与其封闭类型相同”。这意味着有一个与类同名的属性。
所以错误就在这里
/// <summary>
/// There are no comments for Employee in the schema.
/// </summary>
[global::System.ComponentModel.BrowsableAttribute(false)]
[global::System.Runtime.Serialization.DataMemberAttribute()]
public global::System.Data.Objects.DataClasses.EntityReference<Employee> EmployeeReference
{
get
{
return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employee>("HumanResourceModel.FK_EmployeeReferenceMapping_Employee", "Employee");
}
set
{
if ((value != null))
{
((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Employee>("HumanResourceModel.FK_EmployeeReferenceMapping_Employee", "Employee", value);
}
}
}
这是一部分
[global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="HumanResourceModel", Name="EmployeeReference")]
[global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
[global::System.Serializable()]
public partial class EmployeeReference : global::System.Data.Objects.DataClasses.EntityObject
{
我可以通过重命名属性的名称来“修复”此错误(但这会在将来导致大量问题),但是如何从创建的代码中修复此错误?我将外键重命名为映射,但这不起作用。
有任何想法吗?
干杯萨基。
弄清楚了
实体框架:加载多对一实体 https://stackoverflow.com/questions/526530/entity-framework-loading-many-to-one-entity
因为它将引用附加到多对一上
员工.Load()
EmployeeReference.Load()
因为我有一张员工参考表,所以它就死了!
修复=重命名employeeReferenceTable
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)