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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:09:45+00:00 2026-05-28T22:09:45+00:00

I have two tables, Users and TempUsers and I need to do operations on

  • 0

I have two tables, Users and TempUsers and I need to do operations on both of them. I already have my users type defined and I want to add it to the DbContext for both tables. Problem is, it either uses convention to map the type name to a table or using the TableAttribute with the table name specified. Either way I can’t see how to add two dbsets mapping the type to different table names.

I could duplicate the type using either copy + paste or through a UserBase class and two derived User and TempUser classes. Both ways will work but really in the code I want to deal with Users and not have the complexity of Users and TempUsers in the code. After all it’s the repository’s responsibly to deal with where to put the user objects and the business logic shouldn’t have to deal with it.

Advice would be much appreciated. Thanks!

[Explanation Based On Comments]

The reason I have two tables is because the TempUsers is to support a bulk import/update but though atomic transactions on each user. So externally some active directory export or some such will result in calling a service for each user. I have to create/update users and figure out what ones are not being imported but already exist in my database and then delete them. Would be much simpler to truncate the Users table and write directly to that but the Id’s would be different and it would break all the links the users have to different tables, like shipping history for example.

  • 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-28T22:09:46+00:00Added an answer on May 28, 2026 at 10:09 pm

    That is not possible. EF cannot map same class twice within same context. Your single User class can be only mapped to Users table or TempUsers table in single context type. You need either two user classes or two different context types (with different mapping configuration) – one providing access to Users table and second providing access to TempUsers table.

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

Sidebar

Related Questions

I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want
I have two tables users registered_members I want to confirm values from user table
I have two tables Users Users_Role I decided to try to add a foreign
Hi I have two tables (users & friends) I need to connect to the
Below I have two tables users and users_profiles Both are innoDB and collation: utf8_general_ci
I have two tables that need to be related--a users table and an address_book
I have two tables/entities Users and Companies . Both are linked m-n relationship. When
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
If I have two tables - Logins and Users, as follows: Logins LoginIdNo UserIdNo
We have two tables - Tasks and TasksUsers (users assigned to task). Task has

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.