Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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.
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

18 Experts available now in Live!

Get 1:1 Help Now