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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:05:42+00:00 2026-06-13T04:05:42+00:00

How can I manage the two following tables in Entity Framework : Order OrderId

  • 0

How can I manage the two following tables in Entity Framework :


Order

  • OrderId
  • ProductId
  • Date

and


OrderArchive

  • OrderId
  • ProductId
  • Date

In this schema orders are periodically transfered from the table Order to the table OrderArchive…
Neither Table Per Type nor Table Per Hierarchy seems to fit my needs… I want to share the same methods for both object types.

Note that I cannot change the database schema.
Thank you for your help.

  • 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-13T04:05:43+00:00Added an answer on June 13, 2026 at 4:05 am

    Well, if you can’t change the Database schema, … you’ve got a huge limitation !

    If you could change that, I would do an (abstract) OrderBase class, with the common Properties and Methods, and make Order and OrderArchive inherit from it.

    But if you can’t, the only thing I see (someone has maybe a better idea) would be

    create an interface IOrder

    public Interface IOrder {
       int OrderId {get;set;}
       int ProductId {get;set;}
       int Date {get;set;}
    }
    

    make Order and OrderArchive implement IOrder (that won’t change Database schema)

    and create an helper class with common methods.

    public static class IOrderHelper {
       //a fake method
       public static IList<IOrder> GetOrderByDate(IEnumerable<IOrder> orderList, DateTime dt) {
           return orderList.Where(m => m.Date.Date == dt);
        }
    }
    

    But of course, inheritance would be much cleaner, in this case.

    EDIT
    Maybe look for Table per Concrete Type : you might be able to inherit from an abstract class, which wouldn’t be mapped in db, and your Database wouldn’t be changed.

    With Code First, you would have to do

    modelBuilder.Entity<Order>()
        .Map(m =>
                {
                    m.ToTable("Orders");
                    m.MapInheritedProperties();
                });
    modelBuilder.Entity<ArchiveOrder>()
        .Map(m =>
                {
                    m.ToTable("ArchiveOrders");
                    m.MapInheritedProperties();
                });
    

    but I don’t know what you’re using (CodeFirst, ModelFirst, DatabaseFirst) ?

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

Sidebar

Related Questions

I would like to know if there is an existent framework which can manage
I can't manage to figure out why I get an error for the following
How can I use two devices in order to improve for example the performance
I created two tables to manage a multi language article system : table1 is
I have these following two tables: Job Title | PostDate | CompanyId Assitant |
I understand that spring can manage your sessions for you, if configured like so:
i want know how i can manage multiple twitter account on iOS in my
How can i manage user permission? i need a fast method to manage users
how can i manage communication with the database in node.js? is there any module
I'm trying to set image for my UIBarButtonItem and I can't manage to do

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.