0

我在表中添加了两个字段(A,B)。我在进行新注册时填充了这些字段。但是,当我对不包含这些字段的表单进行更新时,它似乎会删除字段(A,B)中的值。当我没有传递值来更新它时,有没有办法在控制器或模型中设置验证以防止它们被更新?

4

1 回答 1

2

Entity framework updates all fields that have changed. EF sees a null value as a change if your field has data.

You should instead be retrieving the record, updating only the fields you want to change, then re-saving.

于 2013-04-08T23:04:53.710 回答