In this article I will explain with an example, how to use System.Data.SqlClient package in .Net Core 6.0 (Razor Pages Web Application).
Explanation
By default like ASP.Net, ASP.Net MVC and .Net Core 3.0, System.Data.SqlClient package is not available in .Net Core 6.0.
Thus, in order to use System.Data.SqlClient package, you need to install the System.Data.SqlClient package from Nuget using Package Manager Console.
Downloading System.Data.SqlClient package
You will need to install the System.Data.SqlClient package using the following command.
Install-Package System.Data.SqlClient -Version 4.8.5
Once System.Data.SqlClient package is successfully installed, you will need to import the System.Data.SqlClient namespace.
As you can see, the SqlConnection class is available to use.