Install these NuGet packages in the project:
- Microsoft.EntityFrameworkCore.Tools
- Microsoft.EntityFrameworkCore.Design
- Microsoft.EntityFramework.SqlServer
Create a folder called “Models” at the root of the project.
Run this command in the package manager console of Visual Studio (make sure you have the correct startup project selected):
Scaffold-DbContext "Data Source=<{SERVER_NAME};Initial Catalog={DATABASE_NAME};Persist Security Info=True;User ID={USERNAME};Password={PASSWORD}" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Source: https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=vs