Changes I did below link
Follow this post https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker
- Didn't need sudo
- In Step 2 use -p 1433:1433 (This allows using localhost and not IP address and port)
- in Step 2 I named my sql-server
- I didn't change the SA Password
- I stopped here (after talk of changing password)
- I use 1 of the following for testing connections and interacting with the server
** NOTE**
If you remove the container you created, you will lose all data.
If you want a separate container for data follow this http://thedatafarm.com/data-access/mashup-sql-server-on-linux-in-docker-on-a-mac-with-visual-studio-code/
If you delete the Data Volume container, you will lose all data.
- From Project Root (where csproj file is) run
dotnet restore
- From Project Root (where newmigration.sh is) run
chmod +x ./newmigration.sh
- From Project Root (where csproj file is) run
dotnet user-secrets localdbconnection "<your connection string here>"
You can use either VS for Mac or VS Code. I prefer VS Code due to better syntax highlighting for sql files, but both will work.
There is a manual piece to adding .sql
files as Embedded Resources. Easier in VS for Mac, but not much.
For non Migrations just add a file to the correct location.
For Migration scripts we need to use the terminal.
- navigate to project root folder where newmigration.sh is
- run ./newmigration version name
- version is current version folder. Must exist
- name is a friendly name for the script. Enclose in quotes if spaces in name
- this uses UTC timestamps for the first part of the name. This is Absolutely necessary to keep order, and the reason for the script.
Whichever type of file was added, it needs to be marked as an embeded resource in the .csproj
file.
VS for Mac
- Right Click In Solution Explorer where you want the file chose
Add Files...
- Add the file
- Right Click the file chose
Properties
- Change Build Action to
EmbededResource
VS Code
- Edit
.csproj
file - Add a
<None Remove="filename"/>
by the others (Prevents Duplicate showings of file in VS) - Add a
<EmbeddedResource Include="filename" />
(Embeds file like it needs to be)
The first time it will have to be run from the command line, since the flag for creating the database is defaulted to False.
run dotnet run --create-db
run dotnet run
(Flags can be added, see Program Start for available flags)
Use VS Mac
Use VS Code