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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:10:33+00:00 2026-05-18T12:10:33+00:00

I have a couple of tables which are related using a multiple field key,

  • 0

I have a couple of tables which are related using a multiple field key, but depending on where the application is deployed, the key may be different.

For example:

-Customer-     -Rep-
CompanyID      CompanyID
StoreID        StoreID
RepID          RepID
CustID  

In some deployments a Rep’s Customers are identified by joining on CompanyID, StoreID, RepID. In other deployments the Rep’s StoreID will be a string of blanks and then the join is on CompanyID, RepID. The Customer will still have values in StoreID.

In SQL I just put an ‘OR StoreID = ” “‘ where we join on the StoreID fields, but I don’t see how I can do that with the entity framework.

I could set up one association for each situation and then use the appropriate one, but unless I can at runtime alias the name to the appropriate association, this would make the application code a bit messy.

Edit:

It looks like I can use the MetadataWorkspace to create the necessary association on-the-fly. I will investigate this.

Edit:

This kind of problem can be solved by splitting the model to use different csdl files (where the associations are defined) depending on which behavior is required. See MerickOWA’s answer and the MSDN article linked. This introduces some minor annoyances, primarily that the designer doesn’t support it, so you’ll be reduced to editing XML files, and also you’ll have to control which csdl resource is used. The csdl is specified in the EF connection string, which by default is in the app.config. To simplify managing this string (I needed control over the database connect string anyway), I wrote a utility class to build my EF connection string. I based this class on the code I found in Fixing the Config: Using Entity Framework in shared libraries.

  • 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-18T12:10:34+00:00Added an answer on May 18, 2026 at 12:10 pm

    One possibility you might look into is trying to split up the edmx file into its subparts the CSDL, SSDL, and MSL.

    The CSDL is your entity object layout while your SSDL is your table layout and the MSL maps between the two.

    Possibly you could try having one CSDL with two or more SSDL/MSL to handle databases with different column layouts.

    I don’t have alot of experience using this advance situation but it certainly seems possible.

    Check out this article on MSDN

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

Sidebar

Related Questions

I have two data tables which have a primary key column in common but
I have a couple of tables which look like this Table 1 user_id |
I have a couple tables where there is a same field added . What
I have a simple database in iPad Application having couple of tables. The UI
I have a mySQl innodb database which has a couple of tables which store
I have a couple of tables which are used to log user activity for
I have a select query in which I have joined a couple of tables
I have a couple of global structs in a binary which are basically tables
I have a couple of tables that need to be be joined. The tables
I have a couple of tables that are transaction tables, and I would like

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.