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

The Archive Base Latest Questions

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

I want to design a base tree node class from which other entity classes

  • 0

I want to design a base tree node class from which other entity classes can derive, I thought it would be like this:

public abstract class BaseTreeNode
{
  public string Id{get;set;}

  public string Name{get;set;}

  public string ParentId{get;set;}

  [ForeignKey("ParentId")]
  public BaseTreeNode ParentNode{get;set;}
}

public class MenuNode:BaseTreeNode
{

}

However, it doesn’t seem to work when try to build some hierarchies with MenuNode class. It threw a SqlException:Invalid object name ‘dbo.BaseTreeNode’ when I called SaveChanges method.

I thought the problem was about the property ‘ParentNode’ as it’s an abstract class.
So, how should I design my classes in this case with entity framework 4.1 code first.

Many thanks!

  • 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:15:47+00:00Added an answer on June 7, 2026 at 8:15 am

    The problem with this approach will be performance. You may want to store multiple types of trees in the DB (Menu/SubMenu, Category/Subcategory), but this type of inheritance will cause all of them to be stored together in a single table. See this question: What are the pros and cons of one master base table which all entities inherit from?

    The question is whether it will ever be necessary to query all types of nodes, regardless of the type of tree.

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

Sidebar

Related Questions

I have an abstract base class from which many classes are derived. I want
I have a base class and several concrete classes that derive from it. Lets
I want to design a c# program which can run program a 3rd exe
I have multiple classes that inherit from one base class, and each class is
I want to design this system which has two major components: Base/core stuff. Never
I want to design a new category this category will be separated from the
In my Base repo I have this code which works fine: abstract class BaseRepo
Base class is Task. There are several derived classes such as PhoneCall, Fax, Email....
I have a design issue which I can't just figure out how to solve.
Say I have a abstract base class and I want to have a pure

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.