0

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:

  • Data source : Microsoft SQL Server (SqlClient)
  • Server name: localhost\SQLEXPRESS
  • Authentication: Windows Authentication
  • Select or enter database name : XXXXX ( the drop down list is correctly populated with all databases available in the server). I just choose the one I want

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?

1
  • 2
    that connected service is not the way to go. edit the projects appsettings.json file Commented Jan 30, 2022 at 10:48

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

This is the correct way. Whatever Visual Studio tries to do, it ultimately only changes the appsettings.json as it's the only connection string source your application needs. You won't install VS on each server your application is to be deployed, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.