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

3

13

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

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

  • VS2019 and SSMS works totally fine. localdb works
  • VS2022 have from the first installation no connection to localDB

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. :)

Chipman answered 23/5, 2022 at 19:9 Comment(5)
Since you haven't shared any code about all anybody can offer is directly from the error message. "Verify that the instance name is correct and that SQL Server is configured to allow remote connections."Resolve
Thanks for you fast answer. Remote connections in enabled and instance name is correct. I really don't know what code i should show you.Chipman
Well good luck then. Still have no idea how you are connecting other than saying you are using VS2022.Resolve
I go to SQL Server Object Explorer -> right click on SQL Server -> Add SQL Server -> select MSSQLLocalDB -> click connect.Chipman
Have you tried opening Microsoft SQL Server Management Studio right-clicking on the instance and looking at the properties, getting the name (something like this ABC12334\SQLEXPRESS) and then copy paste the name into Visual Studio Server Name and refreshing it? At the bottom, select or enter a database name that will show the list of databases.Trap
L
12

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.

Legroom answered 27/5, 2022 at 11:43 Comment(0)
B
0

Follow up to above answer: o Open CMD window o cd C:
o dir SqlLocal*.exe /s /p this should give you the path to localdb provider o cd C:\Program Files\Microsoft SQL Server\150\Tools\Binn Find your instance name o SqlLocalDB.exe i o SqlLocalDB.exe start to start the default instance

Breastwork answered 6/1, 2023 at 17:0 Comment(0)
G
0

You can try deleting the old LocalDB using CMD: sqllocaldb delete MSSQLLocalDB
Then, reconnect to SSMS using: (localdb)\MSSQLLocalDB

Gony answered 15/12, 2023 at 16:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.