Answers for "The property or navigation cannot be added to the entity type because a property or navigation with the same name already exists on entity type"

0

The property or navigation cannot be added to the entity type because a property or navigation with the same name already exists on entity type

public class Device
{
    [Required]
    [DataMember(Name = "key")]
    [Key]
    public Guid Key { get; set; }


    [ForeignKey("DeviceType")]   
    public Guid DeviceTypeId { get; set; } // I assumed primary key of your `DeviceType` entity is `Guid`

    [ForeignKey("ModelType")]  
    public Guid ModelTypeId { get; set; } // I assumed primary key of your `ModelType` entity is `Guid`


    [IgnoreDataMember]
    public virtual DeviceType DeviceType { get; set; }


    [IgnoreDataMember]
    public virtual ModelType ModelType { get; set; }
}
Posted by: Guest on March-24-2022

Code answers related to "The property or navigation cannot be added to the entity type because a property or navigation with the same name already exists on entity type"

Browse Popular Code Answers by Language