MSSQL Database Management

Setting Up Databases for ASP.NET: A Plesk Panel Walkthrough

By the Domain India teamPublished 6 min read
Knowledge base article
Contents (9 sections)

An ASP.NET app and its database are set up in two places: the database and its user in Plesk, and the connection and schema in your code. This walkthrough joins the two for Domain India Windows hosting, with Entity Framework Core as the main example, and shows how to create your tables when your own computer can't connect to the hosted database.

Key takeaways

Create the database and a database user in Plesk under Databases, choosing Microsoft SQL Server. Copy the server name Plesk shows into your connection string, store it in appsettings.Production.json or web.config, and add TrustServerCertificate=True; if you see a certificate error. The SQL Server port is closed from outside, so create your tables by applying migrations when the app starts, or by running a generated SQL script through Plesk's database tools.

The two database canonicals

Step-by-step database creation is in Creating and managing MSSQL databases in Plesk. Every part of the connection string is explained in What to use for the MSSQL connection string. This article covers the ASP.NET side.

1. Choose MSSQL or MySQL

Windows hosting offers Microsoft SQL Server (MSSQL), and it is the natural choice for ASP.NET: Entity Framework Core, ASP.NET Identity and most .NET samples target it. The number of MSSQL databases depends on your plan. Plesk may offer MySQL too; use it only if your application was built for it.

2. Create the database and user in Plesk

  1. Open Databases.
    In Plesk, open Websites & Domains for your domain and go to Databases, then Add Database.
  2. Pick Microsoft SQL Server
    as the database server, and give the database a clear name.
  3. Create a user.
    Add a database user with a long random password. This is separate from your Plesk login.
  4. Note the connection details.
    Plesk shows the server name to use. Copy it exactly; it is not always localhost.

3. Write the connection string

A typical MSSQL connection string for hosting:

text
Server=DB_HOST;Database=DB_NAME;User ID=DB_USER;Password=DB_PASSWORD;TrustServerCertificate=True;

Replace each placeholder with the values from Plesk. TrustServerCertificate=True keeps the connection encrypted but skips the certificate check that newer SQL client libraries do by default; without it you may see "the certificate chain was issued by an authority that is not trusted".

4. Store it in configuration

ASP.NET Core reads it from appsettings.Production.json:

json
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=DB_HOST;Database=DB_NAME;User ID=DB_USER;Password=DB_PASSWORD;TrustServerCertificate=True;"
  }
}

and registers it in Program.cs:

csharp
builder.Services.AddDbContext<AppDbContext>(options =>
    options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));

.NET Framework keeps it in the connectionStrings section of web.config, with providerName="System.Data.SqlClient", and Entity Framework 6 or ADO.NET reads it by name.

Keep your local development connection string in appsettings.Development.json, or a web.config transform, so you never deploy it by mistake.

5. Create the tables

Your computer can't reach the hosted database, because the SQL Server port is closed from outside. That rules out running dotnet ef database update against production from your PC. Two routes work:

Migrate at startup
Call Database.Migrate() when the app starts. The app creates and updates its own tables on the server. Simple; but a failed migration stops the app starting, so test it locally first.
Run a SQL script
Generate a script with dotnet ef migrations script --idempotent -o migrate.sql and run it with the database tools Plesk offers. You control exactly when the schema changes.

A minimal startup migration in ASP.NET Core:

csharp
using (var scope = app.Services.CreateScope())
{
    var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
    db.Database.Migrate();
}

The --idempotent script checks which migrations are already applied, so running it twice is safe.

6. Move existing data

To bring an existing database to the hosting, export it on your computer as a SQL script (in SQL Server Management Studio: Tasks › Generate Scripts, with schema and data) and import it through Plesk's database tools. For large databases, or if the import fails, open a ticket and say what you need moved.

7. Test the connection

After deploying, open a page that reads from the database. If it fails:

ErrorLikely cause
Login failed for userWrong database user or password; not your Plesk login
Cannot open databaseDatabase name typo, or the user isn't linked to that database
Certificate chain not trustedAdd TrustServerCertificate=True
Network-related error or timeoutServer name not copied from Plesk

To see the real exception on ASP.NET Core, turn on the stdout log briefly, as described in Troubleshooting common ASP.NET issues.

8. Back up your database

Backups included with Domain India shared hosting, Windows included, are weekly. For data that changes daily, keep your own copies too: export the database from Plesk before every deployment that changes the schema. Creating backups in Plesk explains both.

9. Which Domain India plan fits

The plans differ mainly in the number of MSSQL databases and sites. The cards show live prices, excluding 18% GST.

ASP Starter
₹164.87/mo + GST
  • 10 GB Storage
  • 50 GB Monthly Bandwidth
  • 1 Website
  • 10 Email Accounts
See plan details
ASP Business
₹328.83/mo + GST
  • 30 GB Storage
  • 150 GB Monthly Bandwidth
  • 5 Websites
  • 50 Email Accounts
See plan details
ASP Enterprise
₹493.70/mo + GST
  • 100 GB Storage
  • Unmetered Bandwidth
  • 15 Websites
  • 100 Email Accounts
See plan details

ASP Starter includes one MSSQL database, ASP Business five and ASP Enterprise fifty.

How do I create an MSSQL database for ASP.NET on Domain India hosting?

In Plesk, open Databases for your domain, click Add Database, choose Microsoft SQL Server, and create a database user with a strong password. Plesk then shows the server name to use in your connection string.

What server name goes in my connection string?

The database server name exactly as Plesk shows it in the database's connection details. It is not always localhost.

Can I run dotnet ef database update from my computer?

Not against the hosted database, because the SQL Server port is closed from outside. Apply migrations at application startup with Database.Migrate, or generate an idempotent SQL script and run it through Plesk's database tools.

Why do I get "the certificate chain was issued by an authority that is not trusted"?

Newer SQL client libraries check the server certificate by default. Add TrustServerCertificate=True to the connection string; the connection stays encrypted.

How many MSSQL databases do I get?

ASP Starter includes one MSSQL database, ASP Business five and ASP Enterprise fifty.

Ready to put your ASP.NET data online? Compare the Windows hosting plans, or open a ticket for help moving a database. Support is on 24/7 live chat, and tickets get a first response within 15 minutes.

ASP.NET hosting with MSSQL

Microsoft SQL Server databases on every Windows plan, managed in Plesk.

See Windows hosting plans

Ready when you are

Get Windows hosting from ₹164.87/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Set Up an MSSQL Database for ASP.NET in Plesk