Does it make sense to use MetadataType to enforce validations in case of Code First?

前端 未结 4 1614
情书的邮戳
情书的邮戳 2021-02-13 11:10

I seem to understand the reason behind taking help of MetadataTypeAttribute to Add Validation to the Model in case of Database First as we want to avoid the changes

4条回答
  •  旧巷少年郎
    2021-02-13 11:49

    I think the questions is where is the difference between data annotations on model and on code first.

    So at first you have data validation

    this is setting up attributes on your code first model and this sets up configuration of database columns and this will set the size and restrictions on your data model. (this once populated usually does not change without migrating data.)

    Model validation

    model validation is your model you are binding your form into. This model would contain more information for your UI.

提交回复
热议问题