Entity Framework Core Database-First Update after initial Scaffold?
Re-runnable scaffold can be used for true DB First approach as answered by Antoine Pelletier.
However more often scaffold is used once for initial import of the model to your code, and then continue with the Code First approach. The process to use reverse engineering to create an Entity Framework model based on an existing database described in https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db
Like you said yourself... The main problem with database first approach : You should never change the model manually and start renaming things etc. Except if you are 100 % sure that your database won't change anymore. If you'r not 100 % sure, just code with the model that has been auto-generated.
Re-Scaffolding will overwrite any changes made directly in the model class, erasing all what you have changed or added.
But you can make partial classes on the side that won't be overwritten by auto mapping :
public partial class TableName
{
public string Name_of_a_property
{get; set;}
}
It's a nice way to add code to your entity while being sure it won't be touched by auto-mapping. Just make sure the partial view has the same name as the auto-generated class and everything should be OK.