Connecting your ASP.NET core application to a local instance of SQLServer
Table of contents
It is no news that one of the best databases to use for asp.net/.net development is SqlServer because of its smooth integration provided with .net(ASP.NET/UWP/Winforms/Xamarin) applications.
Let's get to the process of integrating a local Instance of SqlServer with our our ASP.NET application.....
For you to complete these steps you would need the following:
Microsoft SQL server management studio
SqlServer configuration manager
An ASP.NET project (with EFCore ORM for sqlserver installed )
To install EFcore tools with sqlserver
go to package manager console
and install the following package
Microsoft.EntityFrameworkCore.SqlServer
step 1.
open SqlServer configuration manager
make sure TCP/IP is enabled if this is your first time using a local instance/or connecting to your sqlserver remotely, then right click on TCP/IP and select properties, then select IP addresses, then scroll down to the last section which says Ipall
and enter the TCP port:1433
Step2:
Step 2 is to create a database in your Sqlserver management studio that you intend to use for your asp.net project.
Step 3: is to add the database as your connection string in your appsettings.json
file(in your asp.net project). replace DATABASENAME
with the name of your database
"ConnectionStrings": { "DefaultConnection": "Data Source=.;Initial Catalog=DATABASENAME;Integrated Security=True" }
step4:
Create an ApplicationDBcontext class in your project
and add the dbcontext to your application start-up class under the configure services
and you should be up and running ..... ๐
Subscribe to my newsletter
Read articles from Saruf Ratul directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Saruf Ratul
Saruf Ratul
A Senior Software Engineer with five years of professional experience, specializing in fullstack development, Angular, Asp.Net, MySQL, Oracle, and AWS. A proven track record of managing large scale software engineering projects to support cloud deployments and integrations.