Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-09-07
3
Medium Priority
?
72 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

670 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