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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:27:15+00:00 2026-05-15T04:27:15+00:00

I have these entities (this is just an abstraction I created for this post):

  • 0

I have these entities (this is just an abstraction I created for this post):

  • Language
  • District
  • Description

These are the references between them:

  • District * – 1 Language
  • Description * – 1 Language
  • District 1 – 1 Description

If I fetch like this:

var myFetch = from c in context.Districts
              where c.Id = 10
              select new { DistrictId = c.Id, Lang = c.Language };

and after that, I try to assign it to Description like this:

Description desc = Description.CreateDescription(0, "My description");
desc.DistrictReference.EntityKey = new EntityKey("MyEntities.Descriptions", "DistrictId", myFetch.DistrictId);
desc.Language = myFetch.Lang; //throws error

The error thrown is:

System.InvalidOperationException: The
relationship cannot be defined because
the EntitySet name
‘MyEntities.Descriptions’ is
not valid for the role ‘District’
in association set name
‘MyEntities.District_Description’.

What am I doing wrong?

  • 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-15T04:27:16+00:00Added an answer on May 15, 2026 at 4:27 am

    if myFetch were to be an instance of the class District you could do it programmatically:

    desc.DistrictReference.EntityKey = new EntityKey(  
      String.Format(  
        "{0}.{1}",   
        myFetch.EntityKey.EntityContainerName,   
        myFetch.EntityKey.EntitySetName),   
      "DistrictId", 
      myFetch.DistrictId);  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some entities which have decimal properties on them. These entities' properties are
I have my domain entities. These entities are all together in a class library.
I have 3 entities like this: sorry that this image has a problem that
In my Rails app I have a fairly standard has_many relationship between two entities.
I have two entities, Job and Language , in a many-to-one relationship. The mapping
I have these entities in my database For a given Job , I want
Assume I have these simplified EF generated entities... public class PurchaseOrder { public int
I have two entities: Group and ContactInfo. These are connected with a many-to-many relationship
So I've got some data. There are entities. Entities have an arbitrary number of
I have 2 Entities, related by a many-to-many relationship. Thing<<->>Tag There is one NSArrayController

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.