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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:30:51+00:00 2026-05-25T02:30:51+00:00

Entities public abstract class Person { public string FirstName { get; set; } public

  • 0

Entities

public abstract class Person
{
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public string WorkPhone { get; set; }
  public string Discriminator { get; set; }
}

public class Friend : Person
{
  public string HomePhone { get; set; }
}

public class Family : Person
{
  public string CellPhone { get; set; }
}

public class Colleague : Person
{
  // No home phone
}

Mappings

public class PersonMap : EntityTypeConfiguration<Person>
{
  public PersonMap()
  {
    Property(t => t.FirstName).HasColumnName("First_Name");
    Property(t => t.LastName).HasColumnName("Last_Name");
    Property(t => t.WorkPhone).HasColumnName("Work_Phone");

    Map<Friend>(m => m.Requires("Discriminator").HasValue("Friend");
    Map<Family>(m => m.Requires("Discriminator").HasValue("Family");
    Map<Colleague>(m => m.Requires("Discriminator").HasValue("Colleague");
  }
}

public class FriendMap : EntityTypeConfiguration<Friend>
{
  public FriendMap()
  {
    Property(t => t.HomePhone).HasColumnName("Home_Phone");
  }
}

public class FamilyMap : EntityTypeConfiguration<Family>
{
  public FamilyMap()
  {
    Property(t => t.CellPhone).HasColumnName("Home_Phone");
  }
}

Note: ColleagueMap has no mapping for "Home_Phone"

DbContext

public override void OnModelCreating(DbModelBuilder modelBuilder)
{
  ...
  modelBuilder.Configurations.Add(new PersonMap());
  modelBuilder.Configurations.Add(new FriendMap());
  modelBuilder.Configurations.Add(new FamilyMap());
  ...
}

Entity Framework is telling me that I cannot map two properties to the same column:

System.Data.MetadataException: Schema specified is not valid. Errors:
Each property name in a type must be unique. Property name
‘Home_Phone’ was already defined.

I can’t find any examples of TPH inheritance where multiple subclasses map different properties to the same columns. Is this possible in EF?

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

    Short answer is no. Each property must have its own column. It is not possible to map multiple properties in inheritance hierarchy to the same column.

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

Sidebar

Related Questions

I have two entities: public class Parent() { public ICollection<Child> Children { get; set;
My entities look something like that (simplified): public class Person { public Guid Id
I have the following entities public abstract class Card { public virtual int Id
I have 3 entities: @Entity public abstract class A { @Id public Long id;
I have the following entities public abstract class ProductAttribute { public virtual long Id
I have following structure of my entities: @MappedSuperclass public abstract class BaseEntity { @Id
I have some Entities that look like this: @Entity public abstract class AbstractEntity{ @Id
i have an abstract class public abstract class Document { public int DocumentID {get;
I've the following method which allows me to protect MySQL entities: public function Tick($string)
these are my entities (simplified): public class IdentificationRequest { private int id; private ICollection<IdentificationRequestStateHistoryItem>

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.