Entity Framework 6.1 Updating a Subset of a Record

前端 未结 3 1383
暖寄归人
暖寄归人 2021-02-19 02:06

I have a view model that encapsulates only some of the database model properties. These properties contained by the view model are the only properties I want to update

3条回答
  •  日久生厌
    2021-02-19 02:31

    You based your work on the post https://stackoverflow.com/a/15339512/2015959, but in the other thread the fields that weren't changed (and as such weren't in the attached model) weren't mandatory, and that's why it worked. Since your fields are required, you'll get this validation error.

    Your problem can be solved by the solution provided in question Entity Framework validation with partial updates

提交回复
热议问题