ASP.NET Core with an MSSQL database

Publish an ASP.NET Core application together with its SQL Server database and connection string.

This guide publishes an ASP.NET Core MVC application that stores its data in an MSSQL database. Visual Studio uploads the application through Web Deploy and writes the connection string of your hosted database into the published application.

Before you start

Create the project

  1. Choose the template

    In Visual Studio create a new project, select ASP.NET Core Web App (Model-View-Controller) and click Next.

  2. Turn on authentication

    On the Additional information page set Authentication type to Individual Accounts and click Create. This gives the application a database with user accounts, so there is something to store.

If you already have your own application that uses a database, skip this part.

Prepare the hosting

  1. Download the publish profile

    In the Control Panel open your website, choose Deploy, switch WebDeploy to Enabled on the Visual Studio access card and click Download publish profile. Save the .publishSettings file.

  2. Create the database

    Create an MSSQL database in the Control Panel — see Create an MSSQL database.

  3. Copy the connection string

    Open the database and copy its connection string — see Find your connection string.

Publish with the database

  1. Import the profile

    In Solution Explorer right-click the project and choose Publish. Click Import profile and select the .publishSettings file you downloaded.

  2. Open the publish settings

    Before publishing, click Show all settings.

  3. Fill in the connection string

    In the settings, expand the Database and Entity Framework Migrations sections and fill in the connection string of your hosted database in both of them.

  4. Publish

    Save the settings and click Publish. Visual Studio builds the project and publishes it to your website.

When the publish finishes, open the website in your browser. With the sample project you can register a user to check that the application writes to the database.

Tip

The application running on your website should use the local connection string — the website and the database talk to each other directly inside our network. The remote connection string is meant for connections from outside and requires remote access to be enabled.

Something went wrong?

Still stuck? Our support team is happy to help.
Ask the community Open a support ticket