RK_Web_Solution_White_Transparent
Client Area
Emergency Support
How to install and configure .Net Core with MSSQL Server in Linux system?
Home/Uncategorized / How to install and configure .Net Core with MSSQL Server in Linux system?
How to install and configure .Net Core with MSSQL Server in Linux system?

.NET Core is a platform that allows you to run .NET applications on Linux. However, setting it up requires some extra steps. To use .NET Core with Microsoft SQL Server (MSSQL) on Linux, you need to:

  • First, install the .NET Core SDK.
  • Next, set up the MSSQL Server.
  • Then, configure the firewall and authentication.
  • Finally, use Entity Framework Core or ADO.NET for database connections.

In this guide, you’ll learn how to install and configure .NET Core with MSSQL on Linux, step by step.

System Requirements

Before installing .NET Core, make sure your system meets these requirements:

  • Supported Linux Versions: Ubuntu 18.04, 20.04, 22.04 / Debian 10, 11 / RHEL 7, 8, 9 / CentOS 7 / Fedora 37+ / SUSE 15+
  • Architecture: 64-bit (x86_64) or ARM64
  • RAM: Minimum 512 MB, Recommended 2 GB+
  • Disk Space: Minimum 500 MB free

Pre-Installation Steps

Step 1: Update Your System

Run the appropriate command based on your Linux distribution:

  • Ubuntu/Debian: apt update && sudo apt upgrade -y
  • RHEL/CentOS: yum update -y
  • Fedora: dnf update -y
  • SUSE: zypper update -y
linux-net-core-mssql-00

Step 2: Install Required Libraries

.NET Core requires some extra system libraries. Install them with:

  • Ubuntu/Debian: apt install -y libc6 libgcc1 libgssapi-krb5-2 libicu-dev libssl-dev libstdc++6 zlib1g
  • RHEL/CentOS: yum install -y krb5-libs libicu openssl-libs libstdc++ glibc zlib
  • Fedora: dnf install -y krb5-libs libicu openssl-libs libstdc++ glibc zlib
  • SUSE: zypper install -y krb5 libicu openssl libstdc++6 glibc zlib
linux-net-core-mssql-01

Once done, your system is ready for .NET Core.

Installing .NET Core on Linux for MSSQL Integration

To install .NET Core on a Linux VPS, you first need to add Microsoft's official repository. Then, you can install .NET Core SDK or Runtime as needed.

Follow these steps to install .NET Core on Linux:

Step 1: Add Microsoft Repository

Download the Microsoft Repository by running:

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

linux-net-core-mssql-02

Step 2: Install .NET Core SDK

Install the full toolkit for development:

dpkg -i packages-microsoft-prod.deb

linux-net-core-mssql-03

Step 3: Update System Packages

Since we added a new package source, update your package list:

apt update

linux-net-core-mssql-04

Step 4: Install .NET Core SDK or Runtime

What’s the difference?

SDK (Software Development Kit) – Used for building and running .NET applications (Full toolkit).

Runtime – Only needed to run .NET applications (No development tools).

Since we need to develop applications, we will install the .NET Core SDK:

apt install -y dotnet-sdk-8.0

linux-net-core-mssql-05

To install only the .NET Core Runtime, use:

apt install -y dotnet-runtime-8.0

Note: Installing the SDK includes the runtime, so you don’t need to install both.

Step 5: Verify Installation

To check if .NET Core SDK is installed:

dotnet --version

linux-net-core-mssql-06

To check if .NET Core Runtime is installed:

dotnet --list-runtimes

linux-net-core-mssql-07

The command should display the installed version of .NET, confirming a successful installation.

If you see the installed version in the output, your .NET Core installation is successful!

Install and Set Up SQL Server 2019 Express for .NET Core

Follow these steps to install and configure SQL Server 2019 Express on your Linux system. These steps also work for SQL Server 2022 or newer.

Step 1: Add Microsoft Repository

First, add Microsoft's GPG key and package repository:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc

linux-net-core-mssql-08

add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"

linux-net-core-mssql-09

Then, update your package list:

 apt update

Step 2: Install and Configure SQL Server

Install SQL Server 2019 Express

Run the following command to install SQL Server 2019 Express:

apt install -y mssql-server

linux-net-core-mssql-10

Set Up SQL Server

/opt/mssql/bin/mssql-conf setup

linux-net-core-mssql-11

After installation, configure SQL Server using:

Follow the prompts:

  • Select SQL Server edition -> Enter 3 for Express.
  • Accept the license terms -> Type YES.
  • Set SA (System Administrator) password -> Store it safely!
linux-net-core-mssql-12

After configuration, restart SQL Server. To restart the SQL Service, run the following command in the terminal.

 systemctl restart mssql-server

linux-net-core-mssql-13

Check if SQL Server is Running

Verify the status:

systemctl status mssql-server

If successful, you should see "active (running)".

linux-net-core-mssql-14

Step 3: Install SQL Command Line Tools (SQLCMD)

To manage the SQL Server from the terminal, install SQLCMD:

apt install -y mssql-tools unixodbc-dev

linux-net-core-mssql-15

Now, add SQLCMD to your system path:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

source ~/.bashrc

linux-net-core-mssql-16

Verify Installation

Check if SQLCMD is installed:

sqlcmd -?

If installed correctly, SQLCMD options will be displayed.

linux-net-core-mssql-17

Step 4: Enable Remote Connections (Optional)

By default, SQL Server allows only local connections. To enable remote access:

Edit the Configuration File

Open the SQL Server configuration file:

nano /var/opt/mssql/mssql.conf

Find the [network] section and set tcpport to 1433:

[network]

tcpport = 1433

(If not found, add it manually.)

linux-net-core-mssql-18

Restart SQL Server

Apply the changes:

systemctl restart mssql-server

linux-net-core-mssql-19

Here, you have successfully installed .Net Core SDK. Also, you have installed and configured the MSSQL Server 2019 Express edition.

Conclusion

You have now installed .NET Core SDK and SQL Server 2019 Express on Linux. This setup allows developers to build, manage, and scale .NET applications efficiently.

Leave a Reply

Your email address will not be published. Required fields are marked *