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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:09:08+00:00 2026-05-25T12:09:08+00:00

When I define a model in Entity Framework with Table-per-Type Inheritance, if I have

  • 0

When I define a model in Entity Framework with Table-per-Type Inheritance, if I have a base class/table (not abstract) called person, and two sub entities and tables, adult and child, after creating a child, how would I take the same object and convert it to adult? Once converted to adult, the child record should be deleted, though the base class data in the person table should be retained.

  • 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-25T12:09:09+00:00Added an answer on May 25, 2026 at 12:09 pm

    It is not possible. It is similar problem like here. Simply the entity exists and its type is immutable. The only way to do that is delete child entity (= records from both tables) and create a new adult entity (= new records for both tables).

    This doesn’t look like scenario for inheritance at all.

    Edit:

    The comment about inheritance was targeted for scenario where you mentioned Person, Adult and Child entities. Anyway once your scenario allows changing the type you should think about another solution where the part which can change will be handled by composition.

    For example:

    public class DataSource
    {
        public int Id { get; set; }
        public virtual DataSourceFeatures Features { get; set; }
    }
    
    public class DataSourceFeatures
    {
        [Key, ForeignKey("DataSource")]
        public int Id { get; set; }
        public virtual DataSource DataSource { get; set; }
    }
    
    public class XmlDataSourceFeatures : DataSourceFeatures { ... }
    
    public class DelimitedDataSourceFeatures : DataSourceFeatures { ... }
    
    public class ServiceDataSourceFeatures : DataSourceFeatures { ... }
    

    Now changing a type means deleting dependent current DataSourceFeatures from the database and create a new one but original object remains the same – only relation changes.

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

Sidebar

Related Questions

I'm trying to do a Table Per Hierarchy model in Entity Framework(VS 2008 sp1,
I have a model defined this way class Lga < ActiveRecord::Base validates_uniqueness_of :code validates_presence_of
Say I have a model object 'Person' defined, which has a field called 'Name'.
What options do I have for generating class definitions for LINQ-to-SQL and Entity Framework
I have the following Entity Framework model: It's a very simple model and was
I'd like to define a relationship in an Entity Framework data model that is
I have an Entity Framework model with the Entity Objects T4 Template. For some
I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables
I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other
All, i have the following model defined, class header(models.Model): title = models.CharField(max_length = 255)

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.