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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:51:31+00:00 2026-06-15T15:51:31+00:00

I am doing code first and using a Table-per-type design. I am getting the

  • 0

I am doing code first and using a Table-per-type design. I am getting the following error when I extend the second object to multiple tables:

A value shared across entities or associations is generated in more than one location. Check that mapping does not split an EntityKey to multiple store-generated columns.

My database looks like:

Thanks for the up-vote, editing to add my picture:
enter image description here

The POCO for the project looks like:

public abstract class Project {
    public int ProjectID { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public virtual ICollection<Tag> Tags { get; set; }
    public virtual ICollection<LocationElement> LocationElements { get; set; }


    public abstract string getProjectIdentifier();

}

And for a Location Element:

public enum HowObtainedCodes {
    Provided = 1,
    Estimated = 2,
    Summarized = 3
}
public abstract class LocationElement {
    public int LocationElementID { get; set; }
    public int ProjectID { get; set; }
    public HowObtainedCodes HowObtainedCodeID { get; set; }
}

And for a point:

[Table("ProvidedPoints")]
public class ProvidedPoint : LocationElement {
    public double Lat { get; set; }
    public double Long { get; set; }
    public string Description { get; set; }
}

The link from projects (abstract) to scientific licences works fine, and my objects load / persist as expected. Further I can add LocationElements object in if I make it not abstract. As soon as I extend LocationElements and try to save a ProvidedPoint object I get the above message. My first thought was that the LocationElementID on ProvidedPoints was set as an Identity column, but this was not the case.

My question is: Am I doing something unexpected by trying to link two TPT objects together in this way? Am I missing something else?

  • 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-15T15:51:33+00:00Added an answer on June 15, 2026 at 3:51 pm

    As noted by @leppie above, I had to decorate the LocationElement class with the annotation [Table(“LocationElements”)], which immediately fixed the problem. My understanding with EF was that this was not necessary with the base table for a TPT design, and further I had not done it on the Project / ScientificLicence pair (that is, I only decorated the ScientificLicence object).

    I am assuming this has something to do with the way LocationElements are added/persisted when I save a new Project object. If anyone has any additional insight I would love to know more.

    Hope this helps someone else and a big thank you to leppie!

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

Sidebar

Related Questions

I have the following PHP code doing a very simple select into a table.
I'm using EF code first to define two relations on a complex type with
I am using the following code to first check if a string is located
I'm using EF Code First with the following configuration protected override void OnModelCreating(DbModelBuilder modelBuilder)
I'm doing my first project with EF and I'm planning to go the code-first
Doing code analysis of the project and get the message Reference-counted object is used
I am using 2 Tables (JTable) with their DefaultTableModels. The first table is already
Doing Entity Framework (5) code first, although we are not generating our data model
HI, I have code like this. what I am doing is populating the first
Hopefully a very simple question. But I'm using Code First with an MVC app

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.