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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:45:34+00:00 2026-06-07T08:45:34+00:00

I am trying to make Entity Framework inheritance between two tables. The parent: ParentTable

  • 0

I am trying to make Entity Framework inheritance between two tables.

The parent:

ParentTable
  Id: int primary key
  CustomAttribute: int

The Child:

ChilTable
  Id: int primary key (not the same one as the parent, Child specific Id)
  TCId: int foreign key to parent
  SomeInformation: String

For some reasons I want to keep naming “Id” the primary key of both the ParentTable and the ChildTable. That should not bother EntityFramwork as I created a custom property with another name “CId” for the child Table:

enter image description here

And the Child1 table mapping is the following:

enter image description here

But when I “Validate” the model, VS2010 says…:

Error 3002: Problem in mapping fragments starting at line 103:Potential runtime violation of table Child1's keys (Child1.Id): Columns (Child1.Id) are mapped to EntitySet Parents's properties (Parents.CId) on the conceptual side but they do not form the EntitySet's key properties (Parents.Id).

Basically, I understand that Entity Framework sees a problem in the fact we map a table’s primary key to a property that’s not the key of the Entity but then how are we supposed to use inheritance?

IS inheritance only allowed when there is no primary key in the “Child” table? Should I but my primary key as “simple key”?

Thanks in advance…

  • 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-07T08:45:36+00:00Added an answer on June 7, 2026 at 8:45 am

    EF expects the child’s Id PK to also be a FK to the parent. So Child.Id is both a PK and an FK.

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

Sidebar

Related Questions

I'm trying to make sense of a situation I have using entity framework on
I'm trying to generate my database tables from my Entity Framework model, but I'm
I'm trying to make some changes to our Entity Framework model, which is causing
Using Entity Framework CTP 5 I am trying to make a list of foreign
I am trying to make use of Unity Framework with Entity Framework. Let me
I'm trying to use Entity Framework - Repository Pattern. (Asp.net C#, EF4) I make
I'm trying to use Entity Framework and it put it's connection string into app.config.
I've an Entity Framework model (v.1.0) that I'm trying to extends with a calculated
I am new to entity framework and I am trying to go the Code
I am using Entity Framework 4.3.1 and I am trying to insert a new

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.