How to create and connect SQL server to Visual Studio?

You can connect the SQL server to Visual Studio Code easily by following this guide. Hold up, as you need fowling software to be installed

Installing SQL Server

Install SQL Server as a Custom Installation and press the next button. The setup will start downloading all the components required by SQL Server. Once the downloading finishes, the installation window will appear, and make sure to turn off the firewall and follow the following steps.

  1. Select the installation section from the left sidebar and select “New SQL Server Stand-alone Installation”
  2. Press Next until you reach the “Feature Selection” menu, then select all the features having SQL keywords.
  3. In “Feature Configuration Rule” select the default server or in case the default server already exists, then select the “custom server” and type the server’s name and instance id of your own choice
  4. In the next menu add your current user and start the installation.
  5. Your SQL Server will be installed successfully.

Installing SQL Server Management Studio & Visual Studio Code

Installing SQL Server is straightforward by just selecting the installation location followed by the next button.

Creating a Database in SQL Server Management Studio

Open SSMS and fill server name with your PC name and connect it. Once the server is connected,

  1. Right-click on the “Databases” folder being showed in the left sidebar and select “Create Database”.
  2. Fill in the name of the database and press “OK”.
  3. Your database will be created successfully.

Connection Database to Visual Studio

To add a database to your Visual Code,

  1. Open “Server Explorer” and select the “Connect to Database” button and a menu will appear.
  2. Enter your “PC Name” as your default server name or any other custom server name you want to connect.
  3. Select/Type the respective database you want to connect and press “OK”
  4. Your database will be connected

So, these are all the steps you are required to create SQL Server and connect the database to your Visual Studio Project.

Written by: Muhammad Zubair



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store