Developing C# Applications with SQL Server in Ubuntu: A Beginner's Guide

Developing C# Applications with SQL Server in Ubuntu: A Beginner's Guide
Interested in creating cool C# applications with databases? You don't need a Windows computer—Ubuntu works too! Learn to get started with Ubuntu, .NET SDK, Visual Studio Code, and SQL Server for Linux.

Are you interested in creating cool applications using C# and databases? You might think you need a Windows computer, but guess what? You can do it on Ubuntu too! Let's explore how to get started.

What You'll Need

  1. Ubuntu operating system
  2. .NET SDK
  3. Visual Studio Code
  4. SQL Server for Linux

Ubuntu operating system

Ubuntu is a Linux distribution based on Debian. It is officially released in three editions: Desktop, Server, and Core for Internet of things devices and robot.

Remember, while I've used the term "Ubuntu" https://ubuntu.com/desktop in my original statement, you can apply this concept to some Linux distribution or operating system you prefer. The key is that you have options ranging from the default version to official alternatives and community-made variants.

Official Ubuntu distributions:  Kubuntu Lubuntu Ubuntu Budgie Ubuntu Kylin Ubuntu MATE Ubuntu Studio Xubuntu
Third-party Ubuntu distributions: Bodhi Linux elementary OS Linux Mint Peppermint OS Pop!_OS Zorin OS Linux Lite and more...

.NET SDK

The .NET SDK allows you to develop apps with .NET.

With .NET Core 1.0, which was released on June 27, 2016, Microsoft official supported for .NET on Ubuntu (>= 14.04 LTS).

Given the extended support timeline as indicated on https://endoflife.date/dotnet, this guide will utilize .NET 8. This version has been chosen due to its long-term support, which is scheduled to continue for approximately 2 years and 4 months from now, concluding on November 10, 2026.

If you install the .NET SDK, you don't need to install the corresponding runtime. To install the .NET SDK, run the following commands:

$ sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0

Visual Studio Code

Visual Studio Code (VS Code) is a free, open-source code editor developed by Microsoft. It offers a range of features including syntax highlighting, debugging, intelligent code completion, snippets, and Git integration. VS Code supports extensions for various programming languages and frameworks, making it highly customizable and suitable for a wide range of development tasks. It is available on multiple platforms, including Windows, macOS, and Linux.

For Debian/Ubuntu-based systems, the most straightforward installation method for Visual Studio Code is to obtain and install the 64-bit .deb package https://code.visualstudio.com/docs/setup/linux. If your system has a graphical software center available, you can use that for the installation process.

SQL Server for Linux

SQL Server used to be Windows-only, but now it works on Ubuntu too! Here's how to install it:

Download the public key

$ curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg

Manually download and register the SQL Server Ubuntu repository:

$ curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list | sudo tee /etc/apt/sources.list.d/mssql-server-2022.list

Run the following commands to install SQL Server

$ sudo apt-get update && sudo apt-get install -y mssql-server

Once the package installation is complete, execute $ sudo /opt/mssql/bin/mssql-conf setup and follow the prompts to set the SA password and select your SQL Server edition. Remember, the following editions are available under a free license: Evaluation, Developer, and Express.

After completing the configuration, check to ensure the service is running:

$ systemctl status mssql-server --no-pager

Support the development of the website
This website was created to provide useful and free information to the community. To maintain and develop it, we need support from you.

If you find the website valuable, you can contribute any amount, whether it's $1 or $2, to help keep it running. Your contribution will help cover operating costs, maintenance, and content improvement. Every donation is greatly appreciated and will help us grow sustainably.

Thank you sincerely for your support!