I'm new to Fluent API. In my scenario, a Student
can be in one Grade
and a Grade
can have many Students
. Then, these two statements accomplish the same thing:
modelBuilder
.Entity<Student>()
.HasRequired<Grade>(s => s.Grade)
.WithMany(s => s.Students);
And:
modelBuilder
.Entity<Grade>()
.HasMany<Student>(s => s.Students)
.WithRequired(s => s.Grade);
My question is - how should I choose one statement over the other? Or do I need both statements?