HELP!!!!!. Questions on Devart Entity Model
Posted: Mon 19 Aug 2013 00:55
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
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