Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1.2 KB

ReadMe.md

File metadata and controls

29 lines (24 loc) · 1.2 KB

Create database on docker

docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=password123!!" -p 1433:1433 --name TYPICALAPI_MSSQL_SERVER_2019 --hostname TYPICALAPI_MSSQL_SERVER_2019 -d mcr.microsoft.com/mssql/server:2019-latest

#check database location in docker

docker ps -a

#copy existing database to mssql server using command line

docker cp C:\Users\arane\Downloads\AdventureWorks2019.bak TYPICALAPI_MSSQL_SERVER_2019:/var/opt/mssql/

#create gitignore file for dotnet

dotnet new gitignore

#create generate models and dbcontext from database

dotnet ef dbcontext scaffold "Server=localhost,1433;Database=DatabaseName;User Id=sa;Password=password123!!;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o Models --context-namespace AppDbContext --context-dir Data --force

#create generate models and dbcontext from database without OnConfiguring

dotnet ef dbcontext scaffold "Server=localhost,1433;Database=DatabaseName;User Id=sa;Password=password123!!;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o Models --context-namespace AppDbContext --context-dir Data --no-onconfiguring --force