To connect using SQL Server 2017:
Configuring the Appsettings.json File
{
"ConnectionStrings": {
"DefaultConnection": "Data source=desktop-9mr9dst;initial catalog=test; Persist Security Info=false; User id=sa;pwd= ' 000000 '; Pooling=false; Multipleactiveresultsets=false; Encrypt=false; Trustservercertificate=true "
},
"Logging": {
"Includescopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}
Adding a database service in Startup.cs
Public voidconfigureservices (iservicecollection services) { services. Adddbcontext <ApplicationDbContext> (Options and options. Usesqlserver (configuration.getconnectionstring ("DefaultConnection"))); Services. Addidentity<applicationuser, identityrole>() . Addentityframeworkstores<ApplicationDbContext>() . Adddefaulttokenproviders (); //ADD application services.Services. Addtransient<iemailsender, emailsender>(); Services. Addmvc (); }
Start the project for a connection test.
SQL Server 2017 database connection test in ASP.