Mapping Entities Framework Entity - Participant names cannot be the same as their closing type

I created an entity model from the database and get an error message. "Member names cannot be the same as their closing type." This means that the property has the same name as the class.

So the error is here

    /// <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);
            }
        }
    }

which is part

   [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
{

I can “fix” this error by renaming the property name (but this will cause many problems in the future), but how is it fixed from the generated code? I renamed the foreign key to cartography, but that didn't work.

Any ideas?

Greets Sarki.

+3
source share
2 answers

It turned out

Entity Framework:

Employee.Load() EmployeeReference.Load()

EmployeeReference, !

Fix = employeeReferenceTable

+3

, , ,...

public class Employee
{
    public object Employee { get; set; }
}

, , , , , , , ?

, , , - , EF. , EF.

, , , . , .

+2

Source: https://habr.com/ru/post/1704848/


All Articles