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

前端 未结 4 1607
情书的邮戳
情书的邮戳 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 12:01

    It really makes sense to create a class and use it many times. In code first approach you need data validation which is possible to implement by using data annotations and When you have many props with the same features your life will be easier by doing so. It is not just about overwriting and in this case it has some other reasons. Hope to understand your question well and my answer is appropriate.

提交回复
热议问题