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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:10:34+00:00 2026-05-31T20:10:34+00:00

Hi All I am havinga problem with Entity framework, basically as you can see

  • 0

example simplified class structure

Hi All

I am havinga problem with Entity framework, basically as you can see in the above diagram class A is an abstract class that has two classes that inherit from it B & C.

Each Class has an ID which is not a requirement but was part of the relational structure of the Database design.

I am trying to generate using the EF tools in VS 2008 a model of my Database and then model in the inheritance. I get the model generated fine but the Foreign Keys are still present in the model diagram. I delete those and replace them with the correct inheritance, I also set the Entity Set Names to be the same.

and this is where my problems begin.

The classes do not seem to be working correctly the associations are not working?

Was the removal of the FK correct or should I have left it in place and used the inheritance as well?

I need classes B and C to inherit A in my business layer.

The model doesn’t seem correct and I would be gtreatful for any help in making this model work.

  • 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-31T20:10:35+00:00Added an answer on May 31, 2026 at 8:10 pm

    I think the problem is that you have a separate PK and FK that relates your tables. EF expects that the child tables have a single “id” column, in the child tables, that is both the PK and the FK.

    Here is a snapshot of an example of a database that I have (this was generated by EF, but you see what I’m talking about):

    Example

    You’ll see here that Jobs is the base and the other two derive from Jobs. You’ll see that the Id field in Jobs is the PK, then in the other two tables the Id field is both a PK as well as a FK back to Jobs.

    Like I said, this model was generated by EF (Model first), but I’m pretty sure this is how EF wants to see things, so I don’t think your database will fit into EF’s inheritance structure.

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

Sidebar

Related Questions

We're having a problem testing Entity Framework 4. We've deployed a WCF service that
I have a problem in Entity-Framework, using Code-First, that I couldn't solve. Having entities
I'm having a problem trying to create a Javascript function that checks all the
Essentially, after compiling utility jars w/ ANT, I'm having the problem that all the
All, The problem I am having is that I created a ListView and set
Hi all I am having some problems that I think can be attributed to
I having a weird problem with Entity Framework with MySql database. Here's the code
I am having a problem with Entity Framework in my MVC 3 application. I
I am using the Entity Framework and have got a loop that looks at
I'm having a problem with performance with the entity framework. Here's the scenario. I

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.