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

  • SEARCH
  • Home
  • 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 8719137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:43:09+00:00 2026-06-13T06:43:09+00:00

First said, this is my first experience using the Entity Framework so I apologize

  • 0

First said, this is my first experience using the Entity Framework so I apologize if this ends up being a newbie question. Everything has gone well so far; but, I run into a situation that I am not sure what the best way to handle is.

I need to create a many-to-many relationship; but, the many-to-many table contains more than just the composite key. In this case the Entity Framework does not see to recognize it as a many-to-many structure and so I don’t seem to get the easy ability to get the collections without using the intervening table. Is there a better way to do this?

Simplified Example:

  • A Unit can have many boards and a board could have been in many units
  • When it is in a unit we need to record what slot it was in.

Tables:

Unit
 UnitID(PK)
 UnitName

Board
 BoardID(PK)
 BoardName

UnitBoard
 UnitID(PK,FK1)
 BoardID(PK,FK2)
 Slot

When I pull this into my code using an ADO.NET Entity Data Model, I don’t see an easy way to get the collection of Boards associated to a Unit from the Unit Entity or visa-versa.

Is there a better way to do this or do I just need to use the associated collection of UnitBoards then use that to build the collection of Units/Boards?

This seems I am probably not the first person to went to do something like this. Ex: I was thinking of Books and Owners wanting to also keep the related BookOwner information (like the purchase date).

  • 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-13T06:43:10+00:00Added an answer on June 13, 2026 at 6:43 am

    Even in the updated Entity Framework 5, there is no good solution for this problem. If you have the proper Foreign Key relationships you should be able to access your Boards or Units like:

    Unit.UnitBoards.Boards
    

    or

    Board.UnitBoards.Units
    

    but you won’t have a direct navigation properties (many-to-many navigations) if the many-to-many table has it’s own properties outside of the composite key.

    When filtering you can include them using Include and Select to reduce db calls.

    var myBoards = From Context.Boards
      .Include(i => i.UnitBoards)
      .Include(i => i.UnitBoards.Select(is => is.Unit))
      .Where(...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, some context: I'm a Python developer who has written a medium-sized application using
First of all, I am sorry if this question doesn't belong to SO since
Following the apparent tradition of of using this question as the basis of new
This is a somewhat different question about Tomcat deployment. It has been covered partially
First of all, this isn't for a keylogger, it's for an input in a
first take a look on this picture from localScope app : i have 2
first sorry if its a stupid question but im lost a bit. So when
I have lots of experience building enterprise apps using Java/C# and have become accustomed
To begin with, this is the first Android app I'm writing, and I have
Okay guys, I'm sure this has a very simple solution but my searches are

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.