问题
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