Hi Folks. Please forgive any obvious misunderstandings as I am still learning.
I am using the Devart Entity Model to generate my code from Database First, and have a couple of examples working. A while back when I was experimenting with MVC and validation I found that because the code was generated automatically I would loose any field specific validation that I created if using the DataAnnotation method. I found I needed to use partial classes.
http://msdn.microsoft.com/en-us/library ... .100).aspx
With Devart Entity Model I can automatically create the partial classes which makes putting in the validation much easier. But I need to find out where to put this validation i.e. Range(50,100)
Now the questions.... I have created an entity of Sap2kDatEntities with one table being User
DataModel2.User.cs seems to be the partial class that I can put my code that will not be changed on a regeneration.
DataModel2.User.Generated.cs\User and User seems to be linked together.
This is the generated code for the field RoleId
Where would I put my validation so that it will not be overwritten.
This is the DataModel2.User.cs Partial Class that is generated
So to put in a validation of Range(50,100) for RoleId that would not be overwritten I would need to put my code where..
The next question is simpler. After I have the above working and have saved it in a separate project (DLL) so I can reuse it - will the validation still work...
Many thanks for any advice you can offer a beginner who is trying to get a project off the ground. I cannot use Code First as the database is already created and running.
Dave
HELP!!!!!. Questions on Devart Entity Model
Re: HELP!!!!!. Questions on Devart Entity Model
There is no need to add Data Annotations attributes manually.
Please open your model, navigate to Tools > Entity Developer > Model Explorer and select your template in the Templates node. Set its Validation Framework property to Data Annotations. Then select a particular class property on a diagram (or in Model Explorer) and initialize the needed attributes from the Validation section in the Properties window. Save the model to regenerate the code.
Does this help?
Please open your model, navigate to Tools > Entity Developer > Model Explorer and select your template in the Templates node. Set its Validation Framework property to Data Annotations. Then select a particular class property on a diagram (or in Model Explorer) and initialize the needed attributes from the Validation section in the Properties window. Save the model to regenerate the code.
Does this help?
Re: HELP!!!!!. Questions on Devart Entity Model
Many many thanks for your help I now have the validation working
I found this article which also helped re using the validation
http://odetocode.com/blogs/scott/archi ... ions.aspx
Again many thanks
Dave
I found this article which also helped re using the validation
http://odetocode.com/blogs/scott/archi ... ions.aspx
Again many thanks
Dave