I have a 1: N ratio between Program and Student tables, which EF converts to a navigation property. Now I want to delete all these entries in these students. I started like this:
foreach(Student student in program.Students)
program.Students.Remove(student);
But I am a little skeptical about this.
Than I tried this way:
while (program.Students.Count > 0)
program.Students.Remove(program.Students.ToList()[0]);
But that also seems strange.
Is there any easier way to do this, or if not the best way?
Vajda source
share