ASP.NET MVC w/ Entity Framework - UpdateException -
When I'm experiencing an issue to update an object to use an entity framework in my database .
First of all, this concept is:
A user can be a member of a group, so there are users in a group
Modeling in this database For, I have the following structure:
User: ID name etc.
Group: Name of ID
Group Members: Group ID UserID
Both fields in group member are foreign keys related to User ID and Group ID. When I load it into the unit framework, it is created correctly, in which a group object contains a list of user objects, and each user object has a list of group objects.
However, when I 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 (); EntitySet is unable to update 'GroupMembers' because it has a defined form and no element exists in the element to support the existing operation. I have seen many different types of online pieces which are advising to add the ID field to the group mambar - although if I do this, then a mapping error is found in the EF Is the one who complains about the ID that the ID is not being mapped.
Can someone borrow any other advice, or work?
id < Remove Group Members
from / code> columns. Create a PK for both GroupID
and UserID
to GroupMembers
. Now right-click your model and update it with DB.
EF Designer needs to know that the pair of GroupID
and UserID
are unique, to get cardinality right order.
Comments
Post a Comment