I’m working on an MVC3 project I have created my database on SQL server 2008 then I add it using entity data model, now I have the .edmx I don’t want to generate the code of the classes because till now it’s not stable and I don’t feel the need to do that except to make the validations
I’m wondering if there is a way to make validation directly using the .edmx without generating the code of classes
Need server and client side validation
Cheers
I’m working on an MVC3 project I have created my database on SQL server
Share
You can’t do it from edmx. You can however have classes that add the metadata to the edmx generated classes.
This adds a metadata containing class to the class that was generated by the edmx:
and then you have the metadata class which has the metadata attributes:
Edit:
EF generates all it’s classes as partial. That means you can add functionality in a different file to the same class. We use this feature to add an attribute telling .net that there’s a class that has the metadata information. In this case the class with the metadata for the
Customerclass isCustomerMetadata.It has all the properties that you want decorated with metadata. In this case ID is not actually required to be there.