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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:22:40+00:00 2026-05-27T01:22:40+00:00

Summary of the question: How do i scaffold two or more tables with linq

  • 0

Summary of the question: How do i scaffold two or more tables with linq to entities.

I cant find an example; they always scaffold only one table.

Details:

If I have two tables and I use LINQ to entities with a t4 template for dbcontext capability like such:

Table1 
Name    LastName  PositionId
Jose     j        1

Table2 
PositionPrimaryKey   PositionId   PositionDescription
1                      1             MainProgrammer

If I had these table mapped with linq to entities how would I scaffold them?

Then i put Table1 as my Model class.
I have my employeesentities as dbcontext

But that only creates the values for table 1 and not 2.

If I create a new model that contains both entities, it says is not part of Employeeentities and the class could not be modfied to add my new entity.

  • 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-05-27T01:22:41+00:00Added an answer on May 27, 2026 at 1:22 am

    So, you have a 1:1 relationship between these tables? If yes, I suggest you creating an entity by hand, set its defining query to the necessary join, and map Insert/Update/Delete to stored procedures in the Mapping Details screen. It involves some (quite simple) sql, but it is the cleanest way for your code above.

    If it’s not a 1:1 relationship, you need to modify the t4 template to conditionally create the fields of the linked property (it has to navigate the property, and based on some condition, like you say “if property is called Table2”, create the extra fields). If you have already done so and it doesn’t work, maybe there’s something going on with the selection of properties used by MVC scaffolding. It might use reflection and choose only primitive types.

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

Sidebar

Related Questions

Question Summary: Is there a better method than the one posted below to implement
In a rails project I have two entities, Users and Institutions, they have a
Ok so part two of I have no will power experiment is: Summary Question
Summary of my question: Does NSURLConnection retain its delegate? Detailed question and scenario: I
Clarification/summary for the question -- we're looking for: a hosted bug tracking system, that
A short summary of the question: I have a parent class which is extended
Title edits that reflect a better summary of the question are welcome. I'd like
Summary Below is the full question (a bit complicated in its full form) here's
EDIT: In case the question below looks a bit 'extensive', the summary is that
Question Summary: how can I get the path to the currently active application under

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.