1, about EF and the new database update the settings of the specified field
Perhaps some fields do not want to be updated when EF submits to the database, or update a model to the database yourself!
1. Update data does not update some fields
/// <summary> ///database Specifies update fields/// </summary>[HttpGet] PublicHttpresponsemessage Alteruserinfo (intID) {//first Query and then modify varuser = Dbcontent.k_user. Where (o = o.id = =ID). FirstOrDefault (); User.Name="Week"; //This property does not want to commit to database modificationUser.age =1; //Set container space a field of a model is not committed to a database//Dbcontent.entry is the entire object to be updated to the databasedbcontent.entry<k_user> (user). Property (" Age"). IsModified =false; Dbcontent.savechanges (); returnReturnstringdata (User.Name); }
View Code
2. Update method Optimization (not commit to database update when property is null)
3. Add model Updates directly
Update the settings for the specified field about the EF update database