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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:26:04+00:00 2026-06-05T17:26:04+00:00

I have the scenario where the data from a single table must be in

  • 0

I have the scenario where the data from a single table must be in 2 objects.

[Table]
-Field1
-Field2
-Field3
-Field4

And the class look like this:

[Class1]
-Field1
-Field2
-Class2 object here

[Class2]
-Field3
-Field4

I have set in the Class1 the attribute [NotMapped] over the property of the Class2 which contain the field 3 and 4. I also have added the configuration in the Database Context:

public class ConfigurationClass1 : EntityTypeConfiguration<Class1> {
    public ConfigurationClass1 () {
        Property(o => o.Class2.Field3).HasColumnName("Field3");
        Property(o => o.Class2.Field4).HasColumnName("Field4");
    }
}

The problem is that when I try to use Entity Framework with the Class1 I got :

The property ‘Class2’ is not a declared property on type ‘Class2’.
Verify that the property has not been explicitly excluded from the
model by using the Ignore method or NotMappedAttribute data
annotation. Make sure that it is a valid primitive property.

How can I use Entity Framework Code First with an Entity that has nested object with all the information in a flat table?

  • 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-05T17:26:06+00:00Added an answer on June 5, 2026 at 5:26 pm

    You can do like this only in case Class2 can be recognized by EF CF as a Complex type.

    Briefly:

    1. Class2 shouldn’t contain any references to other EF Entities. Only
      to other Complex types or standard types
    2. Class2 can’t be generic. in this case as a workaround you can create a non-generic nested class and use it in your Class1.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In general, I have the following scenario: Fetch product and its related data from
Scenario: old legacy code in rpg have to consume data from a new web
I have a scenario where data needs to be imported from a CSV file
I have the following scenario: Data from multiple video files needs to be held
I have the following scenario: I have various user's data stored in my database.
Here's the scenario: I have 2 tables with data, one is the 2009 version
Here is the scenario: I have a visual that displays some data The data
My scenario is that I have some payment transaction data in MySQL and some
In my scenario, I have a program that analyzes data input files and produces
I have an existing SQL Server database, where I store data from large specific

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.