Open the solution demo-db.sln
in Visual Studio and run the database project ProductDatabase
Use connection string
data source=(localdb)\ProjectModels;initial catalog=ProductDatabase;integrated security=True;MultipleActiveResultSets=True
docker-compose up --build -d
The script is already in the repository. Steps 1, 2, and 3 are needed only if the database project is modified.
-
Open and build the solution
demo-db.sln
in Visual Studio -
Get sqlpackage from
https://docs.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver15
-
Execute the next command in a CMD terminal to generate the sql script. The database and the login should not exist to ensure that the script includes all the objects.
"C:\Program Files\Microsoft SQL Server\160\DAC\bin\SqlPackage.exe" /Action:script /SourceFile:.\ProductDatabase\bin\Debug\ProductDatabase.dacpac /OutputPath:ProductDatabase.sql /TargetServerName:localhost /TargetUser:sa /TargetPassword:"yourStrong(!)Password" /TargetDatabaseName:ProductDatabase
sqlcmd -S localhost -U sa -P "yourStrong(!)Password" -i ProductDatabase.sql