I have a 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 was using Entity Framework 5, but now I have upraged (by using nuget) to newest version - 6, after doing that I'm encountering an error:
"The property 'TagSourceId' cannot be configured as a navigation property. The property must be a valid entity type and the property should have a non-abstract getter and setter. For collection properties the type must implement ICollection where T is a valid entity type.","ExceptionType":"System.InvalidOperationException"
I have read that topic, but i have no references like described: EF5 to EF6 upgrade - navigation properties are broken
I had the same problem. I removed
InverseProperty
attributes and the problem solved. Hope it helps.