.net - Entity framework delete without key -
I am using unit framework 5 and I am trying to delete the unit that does not have the primary key This means that my table does not even have a primary key.
The scenario is as follows:
I have 3 tables that have the following flow:
Main-preparation - & gt; UserPerTeam & lt; - User
The primary key ID in my main table table is in connection with MainTeamID with the main user ID.
UserPerTeam is the primary key ID with User ID in User User table with UserID.
UserPerTeam has these 2 links and there are some other fields required in that table.
So now when I use the following code, my organization framework breaks up that it is not a primary key:
var upt = new FighterPerTeam {UserID = UserId, TeamID = teamId}; Entities.UserPerTeam.Attach (upt); Entities.UserPerTeam.Remove (upt); Entities.SaveChanges (); So now I get the almighty error:
EntitySet is unable to update 'UserPerTeam' because it is defined and currently in element to support element No element exists Operation
I'm just wondering how I can decide this is a safe way. I know that I can use the following code, but I do not really want to use it as it is a non-unit framework.
var cmd = ("Delete from UserPerTeam where userID =" + userId + "and Team ID =" + Team ID "); Entities.Database.ExecuteSqlCommand (cmd); I almost forgot to forget that I am using lazy loading and that I want to remove the unit in the UserPerTeam table. If your solution also removes the menu or user object, I welcome all suggestions.
Tables without the primary key are read only in the Entity Framework, as long as the stored procedures are mapped for their insertion, updates and deleted tasks. As the accumulated key in the database, both columns are marked in the junction table.
Comments
Post a Comment