layris3 / Daily-learning-experience-record

daily learning experience
0 stars 0 forks source link

EF-navigation property #18

Open layris3 opened 4 years ago

layris3 commented 4 years ago

navigation property provide a way to navigate the association between 2 entities.

   public virtual ICollection<Course> Courses { get; set; }
   public virtual OfficeAssignment OfficeAssignment { get; set; }

the "virtual" keyword indicates that the navigation property can take advantage of an EF-feature called "lazy loading"

and if one property contains mutiple entities,its type must implement the ICollection<T> interface. For example,IList<T> qualifies but no IEnumerable<T> because IEnumerable<T> doesn't implement Add method.