dotnet new webapi -n EfCoreDatabaseFirst
cd EfCoreDatabaseFirst
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.Tools
Turn on docker and run the following command to create a new SQL Server container.
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Password123" -p 1433:1433 --name sql1 -d mcr.microsoft.com/mssql/server:2019-latest
To start the container, run the following command.
docker start sql1
dotnet ef dbcontext scaffold "Server=localhost,1433;Database=EfCoreDatabaseFirst;User Id=sa;Password=YourStrong@Passw0rd;TrustServerCertificate=true" Microsoft.EntityFrameworkCore.SqlServer -o Models