I have a WorkYear class that should be able to reference the previous or next workyear.
public class WorkYear
{
public int Id { get; set; }
public int? PrevId { get; set; }
public virtual WorkYear Prev { get; set; }
public int? NextId { get; set; }
public virtual WorkYear Next { get; set; }
}
The Idea is that one has create 3 workyears A, B and C.
Upon creation of A.
A.prev = null
A.next = null
Upon creation of B,when selected B.Prev = A then A.next becomes = B.
Upon creation of C,when selected C.Prev = B then B.next becomes = C.With only the Prev in the model all is fine for EF. One can assign a Previous one.
Upon creating a migration to extend the model with Next. EF is protesting :
Unable to determine the principal end of an association between the types 'Mapato.Models.WorkYear' and 'Mapato.Models.WorkYear'.
The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
Any suggestions ?