C# – Entity Framework Mapping Oddity – member names cannot be the same as their enclosing type


I have created an Entity Model from a DB, and getting an error "member names cannot be the same as their enclosing type". Which means there is a Property the same name as the Class.

So the error is here

    /// <summary>
    /// There are no comments for Employee in the schema.
    /// </summary>
    public global::System.Data.Objects.DataClasses.EntityReference<Employee> EmployeeReference
            return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Employee>("HumanResourceModel.FK_EmployeeReferenceMapping_Employee", "Employee");
            if ((value != null))
                ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Employee>("HumanResourceModel.FK_EmployeeReferenceMapping_Employee", "Employee", value);

which is part of

   [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="HumanResourceModel", Name="EmployeeReference")]
public partial class EmployeeReference : global::System.Data.Objects.DataClasses.EntityObject

I can "fix" this error by renaming the name of the Property (but this will cause loads of issues in the future) , but how is this fixed from the created code? I renamed the Foreign Key to Mapping but that didn't work.

Any ideas?

Cheers Sarkie.

Best Solution

Figured it out

Entity Framework: Loading Many to One entity

Because it appends Reference onto a many to one

Employee.Load() EmployeeReference.Load()

and since I have a table EmployeeReference it died on its arse!

Fix= rename the employeeReferenceTable