If a table is having multiple relations with other table. e.g. Employee and Appointment tables. Appointment table is having 2 fields as foreign key from Employee table. 1 key is for the Appointment and other key we keep for the employee who has added that record.
Now, in code when we access Employee via Appointment object then it provides reference like Appointment.Employee and Appointment.Employee1
Is there a way we can rename the Employee and Employee1 to a meaningful relation?
Thanks in advance,
You can name your navigation properties anything you want
public class Appointment
{
...other props
public int EmployeeId { get; set; }
public virtual Employee Employee { get; set; }
public int CreatedByEmployeeId { get; set; }
public virtual Employee CreatedByEmployee { get; set; }
}
You can thus call it like : Appointment.Employee or Appointment.CreatedByEmployee