I’m trying to get a one to many relationship mapped with the EF and for some reason it’s proving more difficult than usual. This is my EDMX and DB Schema. The reason I used an auto-increment key on the middle table is because I was told it’s difficult to use composite keys with the EF.
What I need is to be able to do (with a Course entity) someCourse.Students or (with a student entity) someStudent.Courses. Could anyone give me some pointers as to the best way of mapping this?
alt text http://img195.imageshack.us/img195/4053/schemacz.png
alt text http://img22.imageshack.us/img22/8193/edmx.png
If you remove the AssociationID column and make both the StudentID and CourseID the primary key of the StudentCourses table, it will pick up the many-to-many relationship and generate more intuitive entity classes (ie Student.Courses, Course.Students)