How can i write my model files in a better way that i can preserve the recent changes in modal files if i update the .dbmx file from database.
For example i have added validation attributes
[Required(ErrorMessage="Username is mandatory")]
public string Username
{
get { return _username; }
set
{
if (_username != value)
{
_username = value;
OnPropertyChanged("Username");
}
}
}
in one of my modal files and if once i do “Update Modal from Database”
, it got overwritten and lost every thing i changed recently on that file.Please get me a solution or any better design?
You can do this by implementing view models for your presentation layer and applying validation logic there, as I have described here:
https://stackoverflow.com/a/14531849/1043198
This way, you will never make manual changes to your entity mapping classes. These automatically generated classes shouldn’t be modified by you – they are simply used for passing data to and from the database. If you are adding validation or other functionality in here, you’re doing it in the wrong place. This should be done through other classes, such as view models or service layers.