.net core sqlserver connection string for windows serber code example

Example 1: sql server connection string

Standard Security
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;

Trusted Connection
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;

Connection to a SQL Server instance
The server/instance name syntax used in the server option is the same for all SQL Server connection strings.
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;

Using a non-standard port
If your SQL Server listens on a non-default port you can specify that using the servername,xxxx syntax (note the comma, it's not a colon).
Server=myServerName,myPortNumber;Database=myDataBase;User Id=myUsername;Password=myPassword;
The default SQL Server port is 1433 and there is no need to specify that in the connection string.

Example 2: sql connection string in .net core

{
  "ConnectionStrings": {
    "BloggingDatabase": "Server=(localdb)\\mssqllocaldb;Database=EFGetStarted.ConsoleApp.NewDb;Trusted_Connection=True;"
  },
}

Tags:

Sql Example