Add a Connection String
Open the appsettings.json file -
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Add a new object called ConnectionStrings, then a key to use to name the connection (e.g. DefaultConnection), Then enter the details as the value -
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost; Database=DotNetCourseDatabase; Trusted_Connection=false; TrustServerCertificate=True; User Id=sa; Password=password1;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Last modified: 23 September 2024