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

  • Home
  • SEARCH
  • 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 4270606
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:19:45+00:00 2026-05-21T07:19:45+00:00

I have my domain split into multiple Entity Framework models. I have some shared

  • 0

I have my domain split into multiple Entity Framework models. I have some shared entities that span multiple models (named Lookup), however, these are replaced with “using” references using the methods described in Working With Large Models In Entity Framework. However, what makes my case slightly more unique is that I’m also separating these models into multiple databases (one per model).

I’m having a problem inserting one of my shared entities into my common DB. It’s failing with the error:

The member with identity
‘Harmony.Members.FK_ResidentialAddress_ResidenceTypeLookup’
does not exist in the metadata
collection.

That foreign key that it’s referring to does not exist on the “common DB”. But I’m also not working with the entity on the other side of the relationship (named ResidentialAddress); nor do I even have the context that would contain the other entity initialized (named MembersDb). However, both models are compiled into the same assembly.

There are no navigation properties going from Lookup to ResidentialAddress. Though there is a navigation property in the other direction (which I won’t be persisting – only using in memory).

My MetadataWorkspace for the EntityConnection of the CommonDb context was explicitly initialized with only the SSDL/CSDL/MSL for the data required for that database. I have confirmed there is no references to the foreign key mentioned in that set of schema data.

var metaAssembly = typeof(CommonDb).Assembly;
var schemaResources = new string[]
{ 
    String.Format("res://{0}/Common.ssdl", metaAssembly.FullName), 
    String.Format("res://{0}/Common.csdl", metaAssembly.FullName), 
    String.Format("res://{0}/Common.mdl", metaAssembly.FullName), 
}
MetadataWorkspace metadata = new MetadataWorkspace(schemaResources, new []{ metaAssembly });
EntityConnection connection = new EntityConnection(metadata, myDatabaseConnection);

POSSIBLE CLUE: It does work when I go into the generated classes and remove all of the EdmRelationshipAttribute attributes along with their paired EdmRelationshipNavigationPropertyAttribute from the related models (MembersDb).

Key questions:

  1. So why is it that Entity Framework is trying to do something with the relationship that is for an entity that is neither in scope and nor will it be affected by the insertion of the record!?

  2. I am happy to have the generated code remove the attributes mentioned above, but I still want the navigation properties to remain. How would I go about altering the CSDL to achieve that?

NOTE: Persistence of the “child” models is not a priority, nor is the integrity of their now cross-DB foreign keys. These databases are persisted using SQL CE but they were originally generated from a single master SQL Server database.

  • 1 1 Answer
  • 3 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-21T07:19:46+00:00Added an answer on May 21, 2026 at 7:19 am

    If each part of your model is written to a separate database, then perhaps the edmx files should not know about each other (about entities or relationship to entities that do not belong to them).

    How about trying one of the following approaches:
    (To end up with same entities classes for each part, but make EF oblivious of connections between them.)

    1. Remove the “usings” from edmx + cancel auto generation and create classes yourself.
    2. Remove the “usings” from edmx + modify t4 template to read more than one edmx when creating the classes.
    3. Copy edmx files aside so you have two sets of edmxs.
      3.a. Use set #1 for auto generation of entities.
      3.b. Modify set #2 by removing the “usings” and use for generation of repository classes (objectsets).

    Let me know if one of these works.

    Good luck,
    Danny.

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

Sidebar

Related Questions

I have a domain with host www.mydomainhost.com . Now i got another domain named
I have a view model like this: public class EditVM { public Media.Domain.Entities.Movie Movie
I have some controllers in my grails application:- LoginController LogoutController SearchableController cirnele.SearchAllController com.ten.cirnelle.domain.CustomerController com.ten.cirnelle.domain.ProjectController
We have split our application so that package A handles data from one external
We have multiple offices, and within each office there are multiple departments (some departments
I have a domain model that has the concept of an Editor and a
I have a v-large number of hierarchical structures (or DTO's) that are shared across
lets say that we are studding a url string: http:/domain.com/en/#the-file.html/section-4 where i have codified:
I have a code like this: @dns = #{params[:domain].split('/').reverse.join('.')}.#{params[:zone]} w = Whois::Client.new @r =
I have domain classes => many-to-many and associate them using addTo. class Books {

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.