Solved

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

Posted on 2016-09-07
3
25 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now