I get this error:
The foreign key component 'SubdivisionHOAId' is not a declared property on type 'SubdivisionHOA'. Verify that it has not been explicitly excluded from the model and that it is a valid primitive property.
Here is my model. I don't understand what I need to do, as my understanding is that if I've specified [ForeignKey("SubdivisionsHOA")], it refers to my navigation property in the same class, so shouldn't it try to link on the 'Id' of SubdivisionHOA? I've been grappling with this for hours:
public partial class ContentArticleHOAsubdivision
{
public int Id { get; set; }
[ForeignKey("ContentArticleHOA")]
public long ContentArticleId { get; set; }
[ForeignKey("SubdivisionsHOA")]
public short SubdivisionHOAId { get; set; }
public virtual ContentArticleHOA ContentArticleHOA { get; set; }
public virtual ICollection<SubdivisionHOA> SubdivisionsHOA { get; set; }
}
public partial class SubdivisionHOA
{
[Key, ForeignKey("TopTierDivisionHOA")]
public short Id { get; set; }
public string Name { get; set; }
public virtual TopTierDivisionHOA TopTierDivisionHOA { get; set; }
}
Try this, add a property of the related entity type, in your case SubdivisionHOA, and add foreign key attribute to that property
public partial class ContentArticleHOAsubdivision
{
public short SubdivisionHOAId { get; set; }
[ForeignKey("SubdivisionsHOAId")]
public virtual SubdivisionHOA SubdivisionHOA {get;set;}
}