After switching to EF6 - the property cannot be configured as a navigation property

I have the following class:

[Table("TagSource")]
public class TagSource
{
    public TagSource()
    {
        this.DataSources = new HashSet<DataSource>();
    }

    [Key]
    public int TagSourceId { get; set; }
    ...
    public bool IsHistorical { get; set; }
    public Nullable<int> ModifiedEntryId { get; set; }
    ...
    public int? AttachedTagSourceId { get; set; }        

    [ForeignKey("AttachedTagSourceId"), InverseProperty("TagSourceId")]
    public virtual TagSource AttachedTagSource { get; set; }

    [ForeignKey("ModifiedEntryId"), InverseProperty("TagSourceId")]
    public virtual TagSource ModifiedEntry { get; set; }
}

I used Entity Framework 5, but now I had a disturbance (using nuget) up to the latest version - 6, after which I encountered an error:

"The TagSourceId property cannot be configured as a navigation property. The property must be a valid object type, and the property must have no abstract getter and setter. For collection properties, the type must implement ICollection, where T is a valid object type.", "ExceptionType" : "System.InvalidOperationException"

I read this topic, but I have no links as described: Upgrading EF5 to EF6 - navigation properties are corrupted

+3
1

. InverseProperty, . , .

+1

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


All Articles