Cześć
Zacząłem się zastanawiać czy tak naprawdę potrzebuję tworzenie relacji w bazie danych przy użyciu encji w podejściu code first.
Tutaj przykład z innej stronki:
public class Student
{
public Student() { }
public int StudentId { get; set; }
public string StudentName { get; set; }
public int StdandardRefId { get; set; }
[ForeignKey("StandardRefId")]
public virtual Standard Standard { get; set; }
}
public class Standard
{
public Standard()
{
StudentsList = new List<Student>();
}
public int StandardId { get; set; }
public string Description { get; set; }
public virtual ICollection<Student> Students { get; set; }
}
Nie mógłbym stworzyć takich encji ?
public class Student
{
public int StudentId { get; set; }
public string StudentName { get; set; }
//poprawione
public int StdandardRefId { get; set; }
}
public class Standard
{
public int StandardId { get; set; }
public string Description { get; set; }
}
Wtedy wyciągać dane zupełnie oddzielnie i zapisywać go do jakiegoś ViewModelu który mógłby wyglądać tak:
public class StandardViewModel
{
public int StandardId { get; set; }
public string Description { get; set; }
public List<Student> Students { get; set; }
}
Istnieją jakieś większe plusy pierwszego podejścia ?