- Set
sa
password in thedocker-compose.yml
file
i.e. Uncomment theSA_PASSWORD
variable's line - To connect using e.g. ManagementStudio, (temporarily) uncomment the
ports:
section & choose an available port in thedocker-compose.yml
- Create MSSQL's directory & ensure it is read/writeable to the MSSQL's process (ID 10001):
$ mkdir -p ./volumes/dbserver/ $ sudo chown 10001 ./volumes/dbserver/
- Start the database container
$ docker-compose up -d dbserver
- Connect to the server as
sa
& create the user & the database
nb: use the<PASSWORD>
that is specified in theappsettings.json
fileCREATE LOGIN ttt WITH PASSWORD = '<PASSWORD>' CREATE DATABASE itemttt USE itemttt CREATE USER ttt EXEC sp_addrolemember 'db_owner', 'ttt' EXEC sp_change_users_login 'Update_One', 'ttt', 'ttt'
- Re-comment the
ports:
andSA_PASSWORD
sections of thedocker-compose.yml
file and recreate the container$ docker-compose up -d dbserver
- Run a
bash
prompt from within a container to run Dotnet Entity Framework's migration$ docker-compose run --rm webserver /bin/bash # Now, we're in a container: $ dotnet ef database update $ exit
If there is initially no login in the database, the default one is created (cf. LoginController.cs):
- login: admin
- password: 123
$ dotnet tool install --global dotnet-ef
$ cd app/
$ ~/.dotnet/tools/dotnet-ef migrations add <migration>
$ ~/.dotnet/tools/dotnet-ef database update