I have a department entity:
public class Department : AuditableBaseEntity
{
public Company Company { get; set; }
public Field Field { get; set; }
public Employee Employee { get; set; } // Department Manager
public string Description { get; set; }
public Department ParentDepartment { get; set; }
public virtual ICollection<Employee> Employees { get; set; } // Other employees of the department
public virtual ICollection<DepartmentSurvey> DepartmentSurveys { get; set; }
public virtual ICollection<OvertimeAttendance> OvertimeAttendances { get; set; }
public virtual ICollection<WorkAttendance> WorkAttendances { get; set; }
public virtual ICollection<Job> Jobs { get; set; }
public virtual ICollection<Event> Events { get; set; }
public virtual ICollection<Project> Projects { get; set; }
public virtual ICollection<DepartmentTask> DepartmentTasks { get; set; }
}
When i try to Add-Migration this error occurs: Unable to determine the relationship represented by navigation property 'Department.Employee' of type 'Employee'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
Which is the best practice in my case? Creating a mid table named EmployeeJob or JobEmployee and adding a role enum in this mid table, and then defining the manager in there, then delete the
public Employee Employee { get; set; } // Department Manager
line
and change line
public virtual ICollection<Employee> Employees { get; set; }
to this:
public virtual ICollection<EmployeeJob> EmployeeJob{ get; set; }
or leave all as it is and configure it in somewhere else (i don't know .net core much so where to configure this) ?