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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:32:35+00:00 2026-05-13T14:32:35+00:00

I am encountering a problem when I go to update an object in my

  • 0

I am encountering a problem when I go to update an object in my database using Entity Framework.

Firstly, the concept is:

A user can be a member of a group, hence a Group contains Users.

To model this in the database, I have the following structure:

Users:
ID
Name
etc.

Groups:
ID
Name

GroupMembers:
GroupID
UserID

Both fields in GroupMembers are foreign keys relating back to the User ID and Group ID. When I load this into Entity Framework, it is modelled correctly in that a Group object has a list of User objects, and each User object has a list of Group objects.

However, when I go to add a User to a Group, I get the following problem:

var group = DAO.GetGroup(GroupID);
var user = DAO.GetUser(UserID);
group.Users.Add(user);
conn.SaveChanges();

Unable to update the EntitySet
‘GroupMembers’ because it has a
DefiningQuery and no
element exists in the
element
to support the current operation.

I have seen various pieces online advising to add an ID field to the GroupMembers table – however if I do that, I get a mapping error in EF that complains about the ID not being mapped to anything.

Would anybody be able to lend some other advice, or a workaround?

Thanks,

Chris

  • 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-13T14:32:36+00:00Added an answer on May 13, 2026 at 2:32 pm

    Remove the ID column from GroupMembers. Create a PK for GroupMembers consisting of both GroupID and UserID. Now right-click your model and update it from the DB.

    The EF designer needs to know that the pair of GroupID and UserID is unique in order to get the cardinality right.

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

Sidebar

Related Questions

I'm encountering a problem running a query or detached criteria on an embedded object.
I'm encountering problems with my .NET Framework 3.0 SP1 application. It is a C#
Can someone define what exactly 'POCO' means? I am encountering the term more and
I am using struts to build an image uploading module. However, I am encountering
I am encountering a problem with string formatting while trying to get only the
I'm encountering a build problem for Python 2.6.4 on Snow Leopard. Mac OS X
I want to put an update to my App and I'm encountering heavy issues.
All, I am working on a Zend Framework based web application. We keep encountering
I seem to be encountering a very odd problem which only occurs when trying
Iv been encountering problems with disk space when deploying my app to a pocket

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.