You can re-scaffold the model by running the command that you originally ran with the -Force option added. That will result in the contents of the specified folder being over-written. Using the Package Manager Console example from the EF Core docs, the revised command becomes:
Alternatively, if you are using CLI commands, it becomes:
dotnet ef dbcontext scaffold "Server=(localdb)\v11.0;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models -f
However, you should consider using Migrations to keep your model and database schema in sync with each other. That way you make changes to the model and then propagate them to the database.
Open your ContextModel.edmx file to display the model diagram. Right-click anywhere on the design surface, and select Update Model from Database...
In the Update Wizard, select the Refresh tab and select your table then click Finish button.
If we have customize in dbcontext class E.g. add LoggerFactory and then after we are using ('Scaffold-DbContext "Server=(localdb)\v11.0;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force'). this command then all customize changes will be lost.
Use command Add-migration NameOfMigrationfile which create in migration folder at the application level.
If auto migration is not enabled then we can use some below commands in Package Manager Console.
PM > Enable-migrations -force (If automigration not enable)
PM > Add-migration MigrationName
PM > Update-database -force (If add-migration command not working then we can use udate command)
rename folder with scaffolded clasess let's say model->model1
scaffold database with original command
delete model1 folder
but if you have any changes in /model folder you will lose them. i am keeping /Model folder nearly intact and have all changes in /Partial folder (partial classes).
the only thing i need to change manually after rescaffolding isto remove constructor and onconfiguring (etc) from newly created dbcontext class, because i am keeping this code in partial class