In the EF Core you can find a specific scaffolding command.
Forests can repair your DbContext as well as your models. And in my experience, it wonβt cancel any custom partial classes that you made for the DbContext extension, so they continue to work.
You may need to install certain tools by adding them to your project.json (old) / csproj (new)
dotnet cli
dotnet ef dbcontext scaffold --help` Usage: dotnet ef dbcontext scaffold [arguments] [options] Arguments: <CONNECTION> The connection string to the database. <PROVIDER> The provider to use. (Eg Microsoft.EntityFrameworkCore.SqlServer)
This command (executed from the project root directory if you keep your models in the Models folder); 1) updates my models and 2) my DbContext. If you only need updates for your DbContext, I use source-control (git) to undo the changes to the models; save changes to DbContext.
dotnet ef dbcontext scaffold "{connection}" Microsoft.EntityFrameworkCore.SqlServer \ -f --output-dir=Models
Powershell
Additional information here , abbreviated command:
SYNTAX Scaffold-DbContext [-Connection] <String> [-Provider] <String> [-OutputDir <String>] [-Context <String>] [-Schemas <String[]>] [-Tables <String[]>] [-DataAnnotations] [-Force] [-Environment <String>] [-Project <String>] [-StartupProject <String>] [<CommonParameters>] PARAMETERS -Connection <String> The connection string to the database. -Provider <String> The provider to use. (Eg Microsoft.EntityFrameworkCore.SqlServer) -OutputDir <String> The directory to put files in. Paths are relaive to the project directory. -Context <String> The name of the DbContext to generate. .... -Force [<SwitchParameter>] Overwrite existing files.
source share