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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:18:51+00:00 2026-05-13T21:18:51+00:00

I am having trouble with inheritance mapping in Linq to Sql. I am using

  • 0

I am having trouble with inheritance mapping in Linq to Sql. I am using MSDN as a reference and as a basis it sounds good. However the example it gives is a single table inheritance mapping. However, I am trying to do multiple table inheritance to save on table space. Is this possible? So far I have:

[Table(Name="writing_objs")]
[InheritanceMapping(Code="T",Type=typeof(ObjectTypeA), IsDefault=true)] // Only default because a default is required
[InheritanceMapping(Code="N",Type=typeof(ObjectTypeb))]
public abstract class WritingObject
{
    /* ... */

    [Column(Name="obj_tp", IsDiscriminator=true)]
    [StringLength(1)]
    public string ObjectType { get; set; }
}

I then have the different object types defined like so:

[Table(Name="obj_type_a")]
public class ObjectTypeA: WritingObject
{
    /* Object Type A fields */
}

The issue seems to be that I am defining a table attribute in the 2nd type, as I get the following exception:

The inheritance subtype ‘ObjectTypeA’ is also declared as a root type.

Is it possible to keep these fields in separate tables with Linq to Sql or am I going to have to consolidate them all into a single table? Is it necessarily bad to have some extra fields in one table as long as there aren’t too many (some object types might even be able to share some fields)?

  • 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-13T21:18:51+00:00Added an answer on May 13, 2026 at 9:18 pm

    Linq to SQL does not support multiple-table inheritance using a discriminator, even though that is the best design in many cases (it’s the most normalized).

    You’ll have to implement it using associations instead. If you use a mapping layer that converts it to an inheritance-based domain model, it will be easier to manage at higher layers.

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

Sidebar

Related Questions

I am having trouble in using inheritance with Python. While the concept seems too
Having trouble with Delphi XE2 (update2) using MS SQL 2008 R2 (sp 2) or
Having trouble with each function... Will try to explain by example... In my code,
I am having a trouble mapping an embedded attribute of a class. I have
I'm having a bit of trouble with inheritance. if you expand the first menu
I'm using doctrine inheritance mapping to enable various objects to be linked to a
Having trouble using foreach to output the contents of a mysql table. The table
I'm having trouble constructing an efficient query in EF4 using type per table (TPT)
I'm having trouble with SWIG, shared pointers, and inheritance. I am creating various c++
Hi I'm new to JPA and I'm having trouble understanding how it handles inheritance.

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.