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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:56:46+00:00 2026-05-22T14:56:46+00:00

Lets say I have Customer, Order, OrderDetail classes in the business layer (It’s a

  • 0

Lets say I have Customer, Order, OrderDetail classes in the business layer (It’s a simplified version of my problem).

I have also an old (existing) database that has one global table where every row of the table contains the information of Customers-Orders-OrderDetails; for example:

CustomerID, CompanyName,Fax,OrderID, OrderDate,ProductID,UnitPrice,Quantity

(in this way there are duplicated information of a Customer in different rows).

In the future I’ll have a new database (with different table Customers, Orders, OrderDetails), and I want to use the same program.

I want to use EF CodeFirst to mapping to the old database and in the future to the new database

Which is the best solution?

  1. Design a business layer with a global class that contains the information of Customers-Orders-OrderDetails. So the mapping of this class
    with the old database using EF4 in the data layer is trivial.
    In the future I’ll modify both business layer and data layer for the new database.

  2. Design a business layer with Customers, Orders, OrderDetails classes. In this case is it possible to map these classes to the global table of the old database? How ? (the problem is that the Customer-Order is one to many).
    In the future I’ll modify only data layer for mapping the new database.

  • 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-05-22T14:56:47+00:00Added an answer on May 22, 2026 at 2:56 pm
    1. This will work for now and later you will have to modify everything working with a global class – it can be a lot of work.
    2. It is not possible to map one table to three entities where two have one-to-many relation between them with EF.

    Use third approach. Load one class as described in first approach but immediately convert result to three classes from the second approach. The reverse operation will be done in case of persisting changes. Wrap this code in single place – repository. Your application will use three classes and it will not have any knowledge about the way how they are persisted. Once you change the database you will only remove additional conversions from the repository and work directly with Customer, Order, OrderDetail loaded and persisted by EF.

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

Sidebar

Related Questions

Lets say i have a table with the following data Customer table: Name amount
I have a table with two columns, customer id and order. Let's say I
let's say that i have an order system. each Order references a Customer Object.
Lets say i have : Func<Customer,bool > a = (c) => c.fullName == John;
Lets say I have a Customer table and a Transaction Table, and I say
Lets say I have the following entities: Customer, Account, Agreement, Sub-agreement, sub-agreement-account. A customer
Lets say that I have three tables, customers, orders and orderDetails. I'm doing this:
Lets say I have a Customers table and an Orders table with a one-to-many
Let's say I have a Customer table which has a PrimaryContactId field and a
Lets say I have one table called REVIEWS This table has Reviews that customers

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.