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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:39:00+00:00 2026-05-17T18:39:00+00:00

I have two tables, Customer and CustomerConfiguration that should have a one-to-one mapping. What

  • 0

I have two tables, Customer and CustomerConfiguration that should have a one-to-one mapping. What I did was make customerId the primary key (and identity) for Customer, and then created a customerId field in CustomerConfiguration that is unique and is mapped to the Customer.customerId.

So this seems to give me what I need, and EF4 picks up on this okay (Im using RIA as well) in that it sees Customer to CustomerConfiguration as a 1 – 0..1 mapping.

But, never having done this, is this the right way to do this? Are there any gotchas that I need to watch out for?

  • 1 1 Answer
  • 2 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-05-17T18:39:00+00:00Added an answer on May 17, 2026 at 6:39 pm

    Sounds fine to me.

    Customer table should have CustomerID PK, and other fields.

    CustomerConfiguration table should have CustomerConfigurationID and CustomerID PK/FK.

    Only point i’d make is remove the FK from the “CustomerConfiguration” entity (EF will put this in if you said “Include Foreign Keys in Model”).

    You should be able to get the CustomerConfiguration by doing this:

    var someCust = ctx.Customers.SingleOrDefault(c => c.Id = 1); // get a cust
    var someCustConfig = ctx.Customers.CustomerConfiguration;
    

    That will use the “Navigational Property”.

    Other point i’d make it decide on lazy loading.

    By default it’s on, which means the above code will cause 2 database hits.

    If you turn it off, and do this:

    var someCust = ctx.Customers.Include("CustomerConfiguration").SingleOrDefault(c => c.Id = 1); // get a cust
    var someCustConfig = ctx.Customers.CustomerConfiguration;
    

    It will result in only 1 database hit, as it will ‘eager-load’ the relationship via an inner join.

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

Sidebar

Related Questions

I have two tables, one with products and a foreign key for the customer.
I have two tables, one is a Product Customer mapping and another is a
For example, I have two tables. Name: Customer Primary key: idCustomer AnotherColumn: name Foreign
I have two tables in my database that look like that: Customer: C_ID city
Ok, so I have two tables in MySQL. One table holds customer information, the
Given that I have two tables Customer (id int, username varchar) Order (customer_id int,
I have two tables, one called customer and one called customer_attributes . The idea
I have two tables tied by a foreign key. Example: Customer -> CustomerType I've
I have two tables. One contains Potential Customer information along with their Vehicle requirements
I have two tables customer and activation that I would like to join. Here

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.