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 9009617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:14:49+00:00 2026-06-16T02:14:49+00:00

i created a db-model with the entity framework wizzard in Visual Studio. There are

  • 0

i created a db-model with the entity framework wizzard in Visual Studio. There are 2 tables (job, stocktype) which are related to each other with the table stocktype2job.

enter image description here

Job <------- no direct relation / navigation property --------> StockType
 |                                                                  |
 |                                                                  |
 ---------------------> StockType2Job ----------------------------->

With a Job Object, i could do something like this …

EntitiesObject db = new EntitiesObject();
Job job = db.Jobs.SingleOrDefault(j => j.IdJob == 40);

List<StockType> stockTypes = new List<StockType>;
foreach (StockType2Job st2j in job.StockType2Jobs)
    {
        stockTypes.add(st2j.StockType);
    }

That should work just fine. But is there a way to create a navigation property in the job entity so i can write something like this?

EntitiesObject db = new EntitiesObject();
Job job = db.Jobs.SingleOrDefault(j => j.IdJob == 40);

List<StockType> stockTypes = job.StockTypes; // <<-----

Thanks for your kind Help
Apo

  • 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-16T02:14:50+00:00Added an answer on June 16, 2026 at 2:14 am

    It is clear (from the self reference) that StockType2Jobs does not only contain foreign keys to StockType and Job, so you can’t map a many-many relationship with a navigation property job.StockTypes. So you can’t do anything else then collecting StockType via job.StockType2Jobs. But that’s not a big deal:

    List<StockType> stockTypes = job.StockType2Jobs.Select(x => x.StockType);
    

    You might get tempted to wrap this in an unmapped property job.StockTypes, but usually it’s not a good idea to do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created an Entity Framework model that contains two tables from the Northwind database
I have an Entity Framework model that was generated by the Visual Studio 2008
I have created data base model with entity framework which have relation many to
I have created a Dynamic Data site against an Entity Framework Model I have
I have created a very simple Entity Framework 4.0 model using VS2010 Professional. Ignore
Now that I have built a database. Visual Studio 2008 SP1’s ADO.NET Entity Framework
I try to use SQL Server Compact Edition with Entity Framework in Visual Studio
i have 3 tables in my database and i created a entity model from
I created a new MVC application and added an Entity Framework model generated from
I've created a database model with model-first method using Entity Framework 4.0. I then

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.