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

The Archive Base Latest Questions

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

I have a very small object graph that I’m using: public struct Address {

  • 0

I have a very small object graph that I’m using:

public struct Address
{
    public string AddressLine1 { get; set; }
    public string AddressLine2 { get; set; }
    etc...
}

public class User
{
    public Address HomeAddress { get; set; }
    public Address WorkAddress { get; set; }
    public string FirstName { get; set; }
    etc...
}

Using Entity Framework 4.1, how would I map this structure to one table so that they’re mapped to columns like:

HomeAddressLine1
HomeAddressLine2
WorkAddressLine1
WorkAddressLine2
FirstName
LastName
etc...
  • 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-05T13:05:06+00:00Added an answer on June 5, 2026 at 1:05 pm

    EF doesn’t support structures. You must use class for your Address and map it as complex type:

    public class Address
    {
        public string AddressLine1 { get; set; }
        public string AddressLine2 { get; set; }
    }
    
    public class User
    {
        public int Id { get; set; }
        public Address HomeAddress { get; set; }
        public Address WorkAddress { get; set; }
        public string FirstName { get; set; }
    }
    
    
    public class Context : DbContext
    {
        protected override void OnModelCreating(DbModelBuilder modelBuilder) 
        {
            modelBuilder.Entity<User>()
                        .Property(u => u.HomeAddress.AddressLine1)
                        .ColumnName("HomeAddressLine1");
            // Use the same pattern for all columns of HomeAddress and WorkAddress
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very small program: public static void main(String[] args) { Queue<String> queue
i have a very small utilty app written in c# that works fine on
I have written a very small C# program, that uses a very small SQL
I have a very small VS2008 Winforms project that will not start. When I
I have a very small batch script which is extracting a quite amount of
I have a very small form where a user can enter their zip code
I have a very small office environment, and my team sends created pdfs to
I have vales with very small difference like... 0.000001. I want to visualize them
I have to multiply a very small sized matrix ( size - 10x10 )
I have a requirement to change a very small part of the WPF ComboBox's

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.