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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:52:56+00:00 2026-05-17T02:52:56+00:00

I am trying to resolve a situation I ran into when implementing EF with

  • 0

I am trying to resolve a situation I ran into when implementing EF with my project.

I have absolved the table-per-type approach, in my case the ActionUpdate derives from the ActionHistory and that works fine.

What I am trying to achieve is to derive the ActionUpdate from the ActionHistory, and to have a navigation property at the ActionUpdate which will hold a collection of ActionUpdateDetail entities.

The problem starts with the inheritance: when I delete the ActionHistoryId from ActionUpdate, as per the MSDN sample, and then derive from ActionHistory and do the re-mapping, the ActionUpdateId automatically turns into non-PK property.

That behavior prevents me from mapping to the ActionUpdateDetail entity, as my new derived class does not contain the PK anymore 🙁
I should map ActionUpdate.ActionUpdateId to ActionUpdateDetail.ActionUpdateid

My assumptions:

  1. It is either not possible at all to achieve something like this,
  2. I am just a stupid fart trying to do things the wrong way,
  3. I am doomed 🙂

The cause to the problem

I think it’s important that I share with you the cause to my agony 🙂

I intuitively presumed that ActionUpdateDetail must map to ActionUpdate’s Id, which was wrong.

Instead, it has to map to the ActionHistoryId property of ActionUpdate entity, because the ActionUpdate derives from the ActionHistory.

This little change caused the ActionUpdate table to lose it’s Id column, i.e. it only contains the ActionHistoryId column. The reason for the existence of that single-column table is due to the fact that ActionHistory is an abstract entity, and I need something, i.e. ActionUpdate to hold the set of ActionUpdateDetail entities.

  • 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-17T02:52:57+00:00Added an answer on May 17, 2026 at 2:52 am

    It is possible to use table-per-type inheritance with EF and using the example you provide i’ll write a little drive-through. You just need to follow these steps:

    1. Go to the Entity Data Model (double click on *.edmx)
    2. Delete the association between ActionUpdate and ActionHistory
    3. Right click on ActionHistory, Add > Inheritance, Select ActionHistory as base class and ActionUpdate as derived class
    4. Delete the primary key of ActionUpdate(ActionUpdateID). It doesn’t matter that it is not a PK no longer, because you are going to use the base class PK. From the model’s point of view, your ActionUpdates will be a subset of ActionUpdateID
    5. Open the Map Details window, select ActionHistory and map the id from the database with the field ActionHistoryID. From now on, this entity will use its base class primary key.
    6. Compile or Validate the model and it should work
    7. If you have any problem with the ActionUpdateDetails associated with ActionUpdates (you shouldn’t but you never know with EF) you can check the association constraints (select association > properties panel)

    Important Note: To make a table-per-type inheritance the base and derived classes must establish a 1 to 0..1 relationship. So your model wouldn’t support this type on inheritance. Why do you want to derived the ActionUpdate entity from the ActionHistory entity?

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

Sidebar

Related Questions

I am trying to find a solution that will resolve a recurring deadlock situation
I am trying to clean up my routes and I have a situation I
I have a situation which I can resolve by adding a column which would
I'm trying to resolve an IEnumerable of my dependencies through Autofac, but I need
I am trying to resolve a warning shown on the Facebook linter. The parser's
I'm trying to resolve a hostname in PHP and can't use the builtin gethostbyname
I am trying to resolve a 100% cpu usage by the SQL Server process
I am going nuts here trying to resolve a cascading update/delete issue :-) I
So, I'm having a hard time trying to resolve a college problem... What I
I'm trying to figure out how to resolve relatively referenced resources inside dynamically loaded

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.