Ado.net EDMX model table fields custom validation

▼魔方 西西 提交于 2020-01-06 10:34:26

问题


I have generated the data table model using the option "Generate model from database" in the entity framework and now the model contains the IDE generated code of the models.

The models are working fine and now I have a problem, because I want to add custom validations to the table fields and the error messages & the field names should be taken from the resource file. The validation should be done in the ajax call.

Can anyone help me to add these validations to the automatically generated model code. And also how to map the resource file validation messages and field names to the auto generated Models.

Thanks in advance.


回答1:


You can use the Data Annotations and Buddy classes for validation of EDM generated entities. There is an excellent tutorial from Scott Gu. Data annotations messages can easily be externalized to resource files.



来源:https://stackoverflow.com/questions/12066325/ado-net-edmx-model-table-fields-custom-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!