Create C# apps using SQL Server on macOS
In this section, you will get SQL Server 2017 on Docker. After that you will install the necessary dependencies to create .NET Core apps with SQL Server.
Step 1.1 Install SQL Server
- In order to run SQL Server on your Mac, we are going to use the SQL Server on Linux Docker Image. For this, you need to install Docker for Mac.
- Configure at least 4GB of memory for your Docker environment, also consider adding multiple cores if you want to evaluate performance. You can do this in the Preferences - Advanced option on the menu bar.
- Next, start a new Terminal prompt and use the following commands to download and start the SQL Server on Linux Docker image. Make sure to use a strong password with special characters.
sudo docker pull microsoft/mssql-server-linux
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 -d microsoft/mssql-server-linux
You now have SQL Server running locally in Docker! Check out the next section to continue installing prerequisites.
Step 1.2 Install Homebrew and .NET Core
If you already have .NET Core installed on your machine, skip this step. Install Homebrew, OpenSSL, and .NET Core using the following commands.
-
Install Homebrew.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
Restart the terminal session.
-
Update Homebrew and install OpenSSL.
brew update brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2j.el_capitan.bottle.t ######################################################################## 100.0% ==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz ==> Using the sandbox ==> Caveats … ==> Summary /usr/local/Cellar/openssl/1.0.2j: 1,695 files, 12M
-
Ensure that OpenSSL is set up properly by running the following commands.
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/ ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib
-
Install .NET Core by downloading the official installer. This installer will install the tools and put them on your PATH so you can run dotnet from the Console.
You have successfully installed .NET Core on your Mac. You now have everything you need to start writing your C# apps with SQL Server!
Have Questions?
Happy to help! You can find us on GitHub, MSDN Forums, and StackOverflow. We also monitor the #SQLServerDev hashtag on Twitter.