If I add a new foreign key object and save it, then it works if I'm in the list of foreign key items However, if I remove the list and add new records, then it fails with the "Can not insert value tag in the column" error and the foreign key is omitted from the update query.
EF:
Public category test identification: Identity DBCTTTT & lt; Testusor & gt; {Public TestIdentityDbContext (): Base ("Test Identity Entities") {} Public DBSet & lt; User Archives & gt; Get UserAddresses { Set; }}
Model:
Public Class Test User: Identifier (Public TestUser) {this.Address = new list & lt; UserAddress & gt; (); } Receive public string session ID {}; Set; } Public Virtual ILIT & lt; User Acrobatics & gt; Address {receive; Set; }} {Public (public address)} {Table ("User Address")} Public Partial Class UserAddress {Public Ent ID (Receive; Set;} Public String UserId {get; Set;} Public String BuildingName {get; set;} Public string UnitNumber {get; Set;} public string StreetAddress {get} set;} public string popbox {received; set;} public string postcode {get; set;} public string state government {receive; set;} public button authenticated {received; Set;} public test user tester {add; set;}}
add new address:
public zero UpdateUser (TradeulatorUser user) {var loadedUser = _context.Users.FirstOrDefault (u = & gt; u Username == user.UserName); LoadedUser.SessionId = user.SessionId; //loadedUser.Address.Clear (); Foreign currency (different addresses in user address) {Load Made user.Add more information (address)} _convention.user.edoperate (loaded user); _context.SaveChanges ();}
note that the line Has commented. If this line is commented then everything works and new addresses are already added to the existing address and are saved in the database. Even if there is currently no address for the user, new addresses will be added and this will work. However, if I try to empty the addresses and save the new address, when I get an error, "The value on the table user id can not be inserted into the value user id." The tap does not allow tap "or those rows Something is missing with me?
Comments
Post a Comment