Multiple collections of same type in entity framework
There are two ways to do it;
first : use a tag or enums in the Person
object
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public Group Group { get; set; }
public bool IsFaculty { get; set; }
}
or
public enum PersonType { Teacher, Student };
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public Group Group { get; set; }
public PersonType PropPersonType { get; set; }
}
second : work object oriented with inheritance. This method has my preference because it's easy to manage and expand if you want to expand it.
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public Group Group { get; set; }
}
public class Student : Person
{
public int Year { get; set; }
// other student related fiels.
}
public class Teacher : Person
{
public List<Course> Courses { get; set; }
// other teacher related fields
}
Your Group
is then
public class Group
{
public int Id {get;set;}
public ICollection<Teacher> Teachers { get; set; }
public ICollection<Student> Students { get; set; }
}