Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9081639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:21:46+00:00 2026-06-16T20:21:46+00:00

I am trying to find out how I can represent a bridge table between

  • 0

I am trying to find out how I can represent a bridge table between two entities (many to many relation)
I’m Using Entity Framework Code First

Student:
   StudentID int  PK
   StudentName VARCHAR(50)

Class:
   ClassID int PK
   ClassName VARCHAR(50)

StudentClass:
   StudentID INT PK
   ClassID INT PK

What is the best Class Structure should i Use to represent it in Entity Framework Code First and how can i select from the bridge table and insert in it.

Should I represent the classes it like this:

    public class Student
    {
        public int StudentId { get; set; }
        public string StudentName { get; set; }

        public List<Class> Class { get; set; }

    }


    public class Class
    {
        public int ClassId { get; set; }
        public string ClassName { get; set; }

        public List<Student> Students { get; set; }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T20:21:47+00:00Added an answer on June 16, 2026 at 8:21 pm

    In short: This relationship type between Student and Class is called many to many relationship in EF terminology.

    Entity framework handles tables participating in Many to Many relationship in a nice manner. If the junction table (sometimes called bridge table, association table, link table, etc) only consists of the foreign keys and no other columns, then that table is abstracted by EF and the two sides get a navigational property exposing a collection of the other side.

    What you would need is to generate a Entity Model for the above tables first or define your code first structure like in the following post – Creating a Many To Many Mapping Using Code First.

    Basically, depending on your structure you need to set the method OnModelCreating appropriate to the relationships in your classes.

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    

    Depending on your query needs you will find it informative to look at the following references:

    • Queries involving many to many relationship tables
    • Many To Many Mappings in Entity Framework
    • Many-to-Many Relationships with Entity Framework
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find out weather I can do this or not. I have
I'm trying to find out how I can do an early return in a
I'm trying to find out how I can iterate over the final results of
* I'm trying to find out how the simplest form of identification can be
I can find out the error in my apps. When am trying to execute
Trying to learn Sencha Touch 2 and I can't seem to find out how
I'm trying to execute a SQL command, but I just can't find out why
I am trying to insert an object into my database using Entity Framework where
I am trying to find out how can I strike-through some text in my
I'm using Entity Framework 4.1 Code First and have been trying to add a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.