In all examples I have found about entity framework, they always use ICollection
for object collections.
public partial class Standard
{
public Standard()
{
this.Students = new HashSet<Student>();
this.Teachers = new HashSet<Teacher>();
}
public int StandardId { get; set; }
public string StandardName { get; set; }
public string Description { get; set; }
public virtual ICollection<Student> Students { get; set; }
public virtual ICollection<Teacher> Teachers { get; set; }
}
public partial class Teacher
{
public Teacher()
{
this.Courses = new HashSet<Course>();
}
public int TeacherId { get; set; }
public string TeacherName { get; set; }
public Nullable<int> StandardId { get; set; }
public Nullable<int> TeacherType { get; set; }
public virtual ICollection<Course> Courses { get; set; }
public virtual Standard Standard { get; set; }
}
Questions:
1 Can not work directly with the concrete type, such as List?
public partial class Standard
{
public int StandardId { get; set; }
public string StandardName { get; set; }
public string Description { get; set; }
public virtual List<Student> Students { get; set; }
public virtual List<Teacher> Teachers { get; set; }
}
2 I also read that EF does not work with collections of primitive types. What to do in this case?
3 Because the property needs to be virtual, does the EF make any changes to it?