Create C# apps using SQL Server on Ubuntu
In this section, you will get SQL Server 2017 on Ubuntu. After that you will install the necessary dependencies to create .NET Core apps with SQL Server.
Step 1.1 Install SQL Server
Note: To ensure optimal performance of SQL Server, your machine should have at least 4 GB of memory. If you need to get Ubuntu, check out the Ubuntu Downloads website.
-
Register the Microsoft Linux repositories and add their keys
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
-
Install SQL Server
sudo apt-get update sudo apt-get install mssql-server
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: mssql-server ... Unpacking mssql-server ... Setting up mssql-server ...
-
Setup your SQL Server
sudo /opt/mssql/bin/mssql-conf setup
Microsoft(R) SQL Server(R) Setup To abort setup at anytime, press Ctrl-C. The license terms for this product can be downloaded from http://go.microsoft.com/fwlink/?LinkId=746388 and found in /usr/share/doc/mssql-server/LICENSE.TXT. Do you accept the license terms? If so, please type YES: Please enter a password for the system administrator (SA) account: Please confirm the password for the system administrator (SA) account:
You now have SQL Server running locally on your Ubuntu machine! Check out the next section to continue installing prerequisites.
Step 1.2 Install .NET Core
If you already have .NET Core installed on your machine, skip this step. Otherwise, install it using the following commands.
sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update
sudo apt-get install dotnet-sdk-2.0.0-preview2-006497
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
dotnet-sdk-2.0.0-preview2-006497
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
...
This software may collect information about you and your use of the software, and send that to Microsoft.
Please visit http://aka.ms/dotnet-cli-eula for more information.
You have successfully installed .NET Core on your Ubuntu machine. 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.