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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:24:45+00:00 2026-06-01T08:24:45+00:00

Say I have a table called Users, which contains your typical information: Id, Name,

  • 0

Say I have a table called Users, which contains your typical information: Id, Name, Street, City–much like in the example here:

http://weblogs.asp.net/manavi/archive/2010/12/11/entity-association-mapping-with-code-first-part-1-one-to-one-associations.aspx.

Among other things, this article states:

“Code First has a concept of Complex Type Discovery that works based on a set of Conventions. The convention is that if Code First discovers a class where a primary key cannot be inferred, and no primary key is registered through Data Annotations or the fluent API, then the type will be automatically registered as a complex type. Complex type detection also requires that the type does not have properties that reference entity types (i.e. all the properties must be scalar types) and is not referenced from a collection property on another type.” My Address class meets these criteria: it’s made up of strings and isn’t used anywhere else.

In the app, though (I’m not sure if this makes any difference), we’re calling the Users something else–say, Techs. I want to break out User’s address columns into an Address so each Tech can have its own Address. According to the article above, EF should infer this and take care of the complex type automatically. What I’m getting,though, when the context attempts to give me a Tech, is the following exception:

System.Data.EntityCommandExecutionException: An error occurred while executing t
he command definition. See the inner exception for details. ---> System.Data.Sql
Client.SqlException: Invalid column name 'Address_Street'.
Invalid column name 'Address_City'.
Invalid column name 'Address_State'.
Invalid column name 'Address_Zip'.

It looks like it’s trying to make sense of the Tech.Address property, but is giving each of its sub-properties the wrong name (e.g., “Address_City” instead of “City”).

Any ideas on how I can rectify this?

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

    That is correct behavior. Default convention always prefixes properties mapped to complex type with type name. If you want to use different column names you must map them either through data annotations:

    public class Address
    {
        [Column("City")]
        public string City { get; set; }
        ...
    }
    

    or through fluent API:

    modelBuilder.ComplexType<Address>().Property(a => a.City).HasColumnName("City");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table which contains a field called 'icon_for' which I have been
Say I have a table called myTable. What is the SQL command to return
Say I have a table called xml that stores XML files in a single
Say I have a table called HoursCharged ChrgNum(varchar(10)) CategoryID(uniqueidentifier) Month(datetime) Hours(int) CategoryID is a
Lets say I have one table called REVIEWS This table has Reviews that customers
In PostgreSQL 8.3, let's say I have a table called widgets with the following:
let's say that I have a table called Items (ID int, Done int, Total
Lets say I have a table in MySQL called articles, that has a column
Lets say I have a table in a sql server 2000 database called TransactionType:
Say I have a database called Poll and have these two table structures. poll

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.