Solved

Entity Framework - Many to Many relations, query the foreign keys

Posted on 2016-09-07
3
36 Views
Last Modified: 2016-09-15
Looking at http://www.entityframeworktutorial.net/code-first/configure-many-to-many-relationship-in-code-first.aspx, there is generated a table between Course and Students called CourseStudents. How would I go about manipulating and querying that table for information on relations between Course and Students?
0
Comment
Question by:itnifl
  • 2
3 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41787626
re:  https://www.experts-exchange.com/questions/28968035/Entity-Framework-Code-first-Specify-minimum-one-cardinality-in-a-many-to-many-relation.html#a41787558

In your link above that is doing what I suggested in your previous question.  An intermediate table with two 1:n relationships.

To use it.  Well you can make a query to show all the courses a student has visited, or all the students that visit a course....
0
 
LVL 2

Accepted Solution

by:
itnifl earned 0 total points
ID: 41787749
Yes, that is true. But I don't see how the cardinality is enforced there in entity framework.
Thanks for the reply, but this answer should have been in the other thread at https://www.experts-exchange.com/questions/28968035/Entity-Framework-Code-first-Specify-minimum-one-cardinality-in-a-many-to-many-relation.html#a41787558 or else we mix things up.

On the topic of this thread, I think the following was a good explanation:
http://stackoverflow.com/questions/4253165/insert-update-many-to-many-entity-framework-how-do-i-do-it
0
 
LVL 2

Author Closing Comment

by:itnifl
ID: 41799416
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question