Setup .NET development environment on your Mac within 15 minutes
I was sitting in front of my Mac and didn’t want to waste time switching to my Lenovo windows based laptop.. but the problem was:
One of the project I’m working on is built using .NET Core, EF Core Migrations and it’s configured to use MS SQL Server, so how can I run it on my Mac!?
Visual Studio for Mac
Designed natively for the Mac
Visual Studio for Mac brings the developer productivity you love to the Mac. The experience has been meticulously crafted to optimize the developer workflow for the Mac.
The paragraph above I took from VS website, so click the link (https://www.visualstudio.com/vs/mac/) and download and install Visual Studio for Mac.
MS SQL Server
The best way to have MS SQL Server ready to use on your Mac is by running the SQL Server 2017 container image with Docker.
How do they do it?
Here you have a quickstart by Microsoft Docs
In case you may have any trouble, as I did, please leave that quickstarter and follow the commands below:
Pull the SQL Server 2017 Linux container image from Docker Hub.
sudo docker pull microsoft/mssql-server-linux:2017-latest
Run the container image with Docker
docker run \ --name mac-ms-sql \ --volume /Users/YourUser/Documents/DockerShared:/HostShared \ --env 'ACCEPT_EULA=Y' \ --env 'MSSQL_SA_PASSWORD=P@ssw0rd' \ --publish 1401:1433 \ --detach microsoft/mssql-server-linux:2017-latest
Make sure your Docker container is running
sudo docker ps -a
Connect to SQL Server instance
Do not lose time using SQL Server command-line tool, click the link below to download and install SQL Operations Studio (preview):
Open SQL Operations Studio and connect to the MS SQL Server Docker instance, leave the defaults, except:
Server name: localhost
User name: sa
Click on Advanced button
You’re Done :)
SQL Operations Studio looks cooler than the famous MS SQL Server Management Studio(SSMS), doesn’t it? :)
1. If you are getting this error “Cannot access kerberos ticket. ensure kerberos has been initialized with ‘kinit’…”, chances are you’ve using Integrated Authentication, I mean you are not using SQL authentication, which you should. So, just go ahead and update your connection string to:
2. Not yet discovered (list may be updated in future)
In case you do not like instance name, or you did a typo during the setup, here are commands to remove the SQL Server container you just set up:
sudo docker stop mac-ms-sql
sudo docker rm mac-ms-sql
P.S. The post is meant for myself, in case I forget how to do it again, but if you find it useful, I’m happy ;)