YaKs
YaKs

Reputation: 331

ASP.NET MVC - impossible to change the default SQL connection string

I am using latest version of VS 2022 Community edition. I created a new ASP.NET Core web app (Model-View-Controller) project. I also chose the authentication option "Individual Accounts".

The project runs fine, my problems comes when I try to change the connection string to point to a specific database that I already have on a SQL Server Express installed in the same machine.

I add a new connected service and I click on the three dots (...) to introduce the parameters for the new SQL Server connection string.

The new params are:

I click on "Test Connection" and the test succeeded. I press OK. The resulted connection string value is

Data Source=localhost\SQLEXPRESS;Initial Catalog=abstract;Integrated Security=True

I click Next and Finish and something is shown in the windows but I cannot read it as it closes immediately.

After this, I click on Edit the same connected service and surprisingly the connection string is empty (!).

Could someone tell me what I am doing wrong?

Upvotes: 0

Views: 907

Answers (1)

YaKs
YaKs

Reputation: 331

I just managed to configured the connection to my loca DB by editing the file appsettings.json

{   "ConnectionStrings": {
    "DefaultConnection": "Server=(localhost)\\\\SQLEXPRESS;Database=abstract;Trusted_Connection=True;MultipleActiveResultSets=true" },   "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }   },   "AllowedHosts": "*" }

Not sure if this is the correct way to do it, but it worked

Upvotes: 1

Related Questions