Lesson 17 of 40 Database Intermediate 35 min

Setting Up SQL Server

Learn how to prepare SQL Server for your ASP.NET Core application and configure the connection between your project and the database. This is an important step toward building a real database-driven Student CRUD system.

Part 1: Why You Need SQL Server

In the earlier lessons, your application structure, views, forms, and validation worked well even without a real database. However, real applications need permanent storage so that data remains available after the application stops running.

SQL Server provides that storage. It allows your ASP.NET Core app to save and retrieve structured data such as student records, login information, and business data.

Once SQL Server is connected, your application can move beyond temporary examples and become much closer to a real production system.

Part 2: SQL Server Options for Development

There are several ways to use SQL Server during development. For beginners, the most common choices are:

For most tutorial projects, LocalDB is the easiest option because it integrates smoothly with Visual Studio and does not require a large server setup.

Part 3: What a Connection String Does

To allow your ASP.NET Core application to communicate with SQL Server, you need a connection string. A connection string tells the application:

In ASP.NET Core, the connection string is usually stored in the appsettings.json file.

Part 4: Example Connection String

A common development connection string for LocalDB looks like this:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=StudentDb;Trusted_Connection=True;MultipleActiveResultSets=true"
  }
}

This example connects the application to a LocalDB SQL Server instance and uses a database called StudentDb.

Part 5: Understanding the Main Parts of the Connection String

Part Meaning
Server=(localdb)\mssqllocaldb Specifies the LocalDB server instance
Database=StudentDb Specifies the database name
Trusted_Connection=True Uses Windows authentication
MultipleActiveResultSets=true Allows multiple data operations in some scenarios

Understanding these parts makes it easier to troubleshoot connection issues later.

Part 6: Where to Put the Connection String

In ASP.NET Core, connection strings are usually placed inside appsettings.json. This keeps configuration separate from your application logic.

appsettings.json

This is better than hardcoding the connection details directly inside controllers or other classes. It makes the project cleaner and easier to maintain.

Part 7: Why This Matters in the Student Project

In your Student CRUD application, SQL Server will be used to store student data permanently. That means:

This is the foundation for turning the tutorial project into a real database-backed application.

Part 8: Common Beginner Mistakes

When setting up SQL Server for the first time, beginners often run into a few common issues:

These problems are normal and usually easy to fix once you understand how the configuration works.

Summary

Setting up SQL Server is a major step in building a data-driven ASP.NET Core application. Once the connection string is configured correctly, your project is ready to work with Entity Framework Core and store data in a real relational database.

VISUAL STUDIO 2026 MADE EASY
Recommended Book

VISUAL STUDIO 2026 MADE EASY

Build real applications with C#, VB.NET, Python, JavaScript, C++, and .NET 10. A practical companion for mastering Visual Studio 2026 step by step.