Does my POST edit action overwrite all fields in E

2019-07-08 09:49发布

问题:

Say I have a database record with 7 fields and I just want to edit the contents of field 1. So I hit my GET EDIT action, it renders the strongly typed view with my viewmodel and I go ahead and update field 1. However, my POST action contains 'mapping' for all fields as below. So will entity framework 'overwrite' all 6 other fields in the underlying database with the unchanged value or will it only just change field 1?

Just looking for further clarification after giving the previous related answer (c# edit method overwrite all or only save changes fields?) some more thought given that I am explicitly specifying each field in the edit method.

EDIT POST method extract -

db.entities.find(x)

            entity.field1= viewmodel.field1;
            entity.field2= viewmodel.field2;
            entity.field3= viewmodel.field3;
            entity.field4= viewmodel.field4;
            entity.field5= viewmodel.field5;
            entity.field6= viewmodel.field6;
            entity.field7= viewmodel.field7;

db.savechanges()

FYI - this is my first proper MVC app.

Many thanks