At the moment I’m mapping my existing DB tables to new EF 4.5 model via Fluent Api. I’ve got a questing on how to map following db structure to classes.
Students(pk Id...)
Courses (pk Id...)
Students_Courses (pk Id, fk StudentId, fk CourseId)
Comments (pk Id, fk Students_Courses Id, comment, dateposted...)
The idea is that I may have many reviews per student_course pair. What is the best way to represent my classes in this scenario?
The problem here is that I’ll probably need to map Comment entity to Students_Courses table and somehow determine to which Student and Course (in terms of classes) this comment belongs.
Any suggestions on the design?
Thanks!
Maybe you’d like to use Entity Framework Power Tools to reverse-engineer your data model into a “code -first” model with
DbContextAPI.You will see that something like a
StudentCourseclass will be generated that looks like this:and
Commentlooking like this:So comments are related with students and courses through
StudentCourse