As you said yourself ... The main problem with the first approach to the database: you should never change the model manually, start renaming something, etc. Unless you are 100% sure that your database will no longer change. If you are not 100% sure, just code with the model that was generated automatically.
Re-Scaffolding will overwrite any changes made directly to the model class, deleting everything that you changed or added.
But you can create partial classes on the side that will not be overwritten by automatic mapping:
public partial class TableName { public string Name_of_a_property {get; set;} }
This is a good way to add code to your entity, being sure that it will not be affected by automatic rendering. Just make sure that the partial view has the same name as the automatically generated class, and everything should be in order.
source share