MSSQL 2022 Database Creation & C# Connection String Guide

How to create Microsoft SQL Server 2022 databases on Plesk Obsidian, user setup, C# appsettings.json connection string, and SSMS remote connection guide.

MSSQL 2022 Database Creation & C# Connection String Guide

Microsoft SQL Server 2022 (MSSQL) delivers enterprise database performance, security, and JSON/Spatial data support for C# ASP.NET Core projects. Learn how to set up MSSQL 2022 databases on Windows Plesk Hosting, configure C# appsettings.json connection strings, and connect remotely via SSMS.

Step 1 — Create MSSQL 2022 Database in Plesk

  1. Log into Plesk Obsidian and click Databases.
  2. Click Add Database.
  3. Select database type as Microsoft SQL Server 2022.
  4. Set database name, username, and a strong password.
  5. Under User Access, enable 'Allow remote connections from any host' and click OK.

Step 2 — Configure C# appsettings.json Connection String

In .NET 8 and Entity Framework Core 8, Microsoft.Data.SqlClient requires SSL certificate validation by default. Include TrustServerCertificate=True to prevent connection errors when using self-signed certificates:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=your_db;User Id=your_dbuser;Password=YourPassword123!;TrustServerCertificate=True;MultipleActiveResultSets=True;"
  }
}
🔒 Production Security Note: Avoid storing plain-text database passwords in production appsettings.json. Use Environment Variables (e.g. ConnectionStrings__DefaultConnection) or Azure Key Vault.

Step 3 — Register DbContext in Program.cs

// Entity Framework Core SQL Server Service Registration
builder.Services.AddDbContext<ApplicationDbContext>(options =>
    options.UseSqlServer(
        builder.Configuration.GetConnectionString("DefaultConnection"),
        sqlOptions => sqlOptions.EnableRetryOnFailure(maxRetryCount: 5, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null)
    ));

Step 4 — Connect via SQL Server Management Studio (SSMS) & Firewall

  • Server name: Server IP Address (e.g. server-ip-address,1433 or mssql.yourdomain.com). If using Named Instances, use ServerIP\SQLEXPRESS notation.
  • Authentication: SQL Server Authentication
  • Login: Database username created in Plesk
  • Password: Database password
  • Encryption Options: Check Trust server certificate in SSMS 19+.

🛠️ Troubleshooting & Error Codes

🔴 SqlException Error 26 — Error Locating Server/Instance Specified

Cause: Server IP/Port specified incorrectly, Port 1433 blocked by Windows/Plesk Firewall, or SQL Server Browser service stopped.

Fix: Specify port as IP,1433 in connection string. Enable Inbound Port 1433 TCP in Windows Firewall and confirm SQL Server Browser service is running.

🟡 SqlException: Connection successfully established with server, but error during login

Cause: SSL certificate trust validation error in .NET 8.

Fix: Append TrustServerCertificate=True; to your connection string.

🔵 SqlException (0x80131904): Cannot open database requested by login

Cause: Typo in database name or user lacks access permissions.

Fix: Verify user permissions and database name in Plesk Databases menu.

Last updated on August 10, 2026
Edit this page on GitHub