sql-serverdatabasevisual-studio-2019visual-studio-2022localdb

Visual Studio 2022 localdb ((localdb)\MSSQLLocalDB) (ASP.NET Core)


Visual Studio 2022 localdb ((localdb)\MSSQLLocalDB) (running on ASP.NET Core).

My problem is: I want to change from VS2019 to VS2022.

I can create a new DB and connect it but that is not what I want. I want the connection to the localDB.

What I already tried:

  1. Reinstall VS2022
  2. Reinstall localDB
  3. Disconnect VS2019 and VS 2022 and reconnect. VS2019 works and VS2022 does not
  4. I also followed the Microsoft docs; nothing helped
  5. Followed many Stack Overflow discussions

If I try to connect to (localdb)\MSSQLLocalDB, I get this error

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (.Net SqlClient Data Provider)

If I try to start the ASP.NET Core app, I get this error:

IOException: IDX20807: Unable to retrieve document from: 'System.String'. HttpResponseMessage: 'System.Net.Http.HttpResponseMessage', HttpResponseMessage.Content: 'System.String'. Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)

InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
Microsoft.IdentityModel.Protocols.ConfigurationManager.GetConfigurat ionAsync(CancellationToken cancel)

I know this problem is really wired, but maybe one of you has an idea that helps.

I'm thankful for any help. :)


Solution

  • i was asking the question and found a solution.

    1. Open CMD (windows + R)
    2. SqlLocalDB start MSSQLLocalDB
    3. SqlLocalDB info MSSQLLocalDB
    4. Copy the path of Instance pipe name:. it should be something like: np:\......
    5. use the path as servername when you in go to visual studio -> Add SQL Server

    this works for me.