none
Relating property to join table RRS feed

  • Question

  • I have the classic setup as follows :

    Student
    StudentId
    Name

    Course
    CourseId
    Name

    StudentCourse
    CourseId
    StudentId

    So this is represented quite easily as two entities Student and course with a virtual many to many.

    For each Course a student is on I want to be able to set a status . e.g. Completed, in progress, etc.

    Normally I would put this in the StudentCourse table.

    How do I do this in EF?

    then if I want to list a students courses I would access the Students .Courses property. as part of this list I want to see the students status, but status isn't a property on course, how do I represent this?

    Monday, November 16, 2015 10:33 AM

Answers

  • >>Normally I would put this in the StudentCourse table.How do I do this in EF?

    So is that you are using code first approach(because if with database first, you could just import these tables into the EF, and should not worry about the middle table, you could just create it as what you want in database)? If so, you would have to make a custom middle table and create two one to many relationships:

    Create code first, many to many, with additional fields in association table

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 17, 2015 3:12 AM
    Moderator

All replies