Hi arsar-2618,
First you need to understand two attributes:
>> ICollection<location> locations {get;set}; ICollection<employee> employees {get;set}
Collection navigation property: A navigation property that contains references to many related entities.
>> virutal employee employee {get;set};virutal department department {get;set}
Reference navigation property: A navigation property that holds a reference to a single related entity.
The relationship between the three tables is that employees can only belong to one department but can have multiple positions. A department can have multiple employees, and a location can only have one employee
The definition of the location class allows at most one employee through the employee navigation attribute (refer to the multiplicity of the navigation attribute is 0 or 1), and the definition of the employee class allows each employee to have multiple locations through the locations navigation attribute (with multiple sets of many Navigation attributes) and department navigation attributes belong to only one department.
The main entity in a one-to-many relationship is an entity with set navigation attributes, and a dependent entity is an entity with reference navigation attributes.
More details please refer to this document.
And about HashSet<location>(), I suggest you refer to this thread which explains it in detail.
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.