I currently have a class called EmployeeDetails which looks like below.
public class EmployeeDetails {
public int EmployeeDetailsId { get; set; }
public string Name { get; set; }
public string Title { get; set; }
[ForeignKey("Manager")]
public int? ManagerId { get; set; }
public virtual EmployeeDetails Manager { get; set; }
[ForeignKey("LineManager")]
public int? LineManagerId { get; set; }
public virtual EmployeeDetails LineManager { get; set; }
}
I'm trying to add Manager and LineManager properties which will reference objects of the same type.
When I try and add a migration I get the following error:
Unable to determine the principal end of an association between the types EmployeeDetails and EmployeeDetails.
The Manager property worked as expected before adding the ManagerId, LineManagerId and LineManager properties.
How can I solve it?