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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:51:27+00:00 2026-06-18T07:51:27+00:00

I have standard table-per-type inheritance case in code first approach to an existing schema:

  • 0

I have standard table-per-type inheritance case in code first approach to an existing schema:

[Table("base_object")]
public partial class BaseObject
{
  public BaseObject()
  { 

  }

  [Key]
  [Column("id")]
  public long Id {get; set;}
  [Column("slug")]
  public string Slug {get; set;}
  ...       
}

[Table("user")]
public partial class User: BaseObject
{
  public User()
  {

  }

  [Column("login")]
  public string Login {get; set;}
  [Column("email")]
  public string Email {get; set;}
}

Mapping is straightforward as described in annotations, user.id is primary key and foreign key to base_object.id

In test case, during first call to “Users” repository from Context, EF is generating query:

SELECT 
1 AS [C1], 
'0X0X' AS [C2], 
[Extent1].[id] AS [id], 
[Extent2].[slug] AS [slug], 
[Extent1].[login] AS [login], 
[Extent1].[email] AS [email], 
[Extent1].[BaseObject_id] AS [BaseObject_id]
FROM  [dbo].[user] AS [Extent1]
INNER JOIN [dbo].[base_object] AS [Extent2] ON [Extent1].[id] = [Extent2].[id]

which gives an error, because column “user.BaseObject_id” does not exists!
Whitout this line: *[Extent1].[BaseObject_id] AS [BaseObject_id]* query would be OK.

What am I doing wrong?

I am using EF5.0 with .NET 4.0

  • 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-18T07:51:28+00:00Added an answer on June 18, 2026 at 7:51 am

    It turned out that “…” made the difference.

    BaseObject had a collection:

    [InverseProperty("Object")]
    public virtual ICollection<UserHasObjectRight> UserHasObjectRights { get; set; }
    

    And User had a collection:

    [InverseProperty("User")]
    public virtual ICollection<UserHasObjectRight> UserHasObjectRights { get; set; }
    

    It was causing a strange query generation. I have to remove duplicating collection from base object class and it started to work.

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

Sidebar

Related Questions

I have a standard store schema with an InvoiceLine table that contains Products. I'd
I have a standard table: I want to use jQuery to reformat the table,
Suppose you have a standard org hierarchy table in Oracle. For simplicity sake, assume
I have an HTML table with collapsed and adjacent borders and a standard border
I have an html table that looks like this in a standard HTML 4.01
I have standard source code package under Linux which requires to run ./configure make
I have a table (foos) which is a list of Foos, one row per
I have a pretty standard table set-up in a current application using the .NET
I have a Standard table, which sotres parent, child category relationship...like this. id, parent,
Assume I have a standard HTML table structure like: <table class=table table-striped table-hover table-bordered

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.