Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
822 views
in Technique[技术] by (71.8m points)

asp.net mvc - The specified LocalDb instance does not exist

I've been using a localDB named 'Projects' for a while now. This is the same database that is created by default ASP.NET MVC 5 project. However, suddenly it stopped and I'm not able to connect to it nor restart it using

SqlLocalDb start Projects

I get

The specified LocalDB instance does not exist.

I see the folder in

C:Users[My UserName]AppDataLocalMicrosoftMicrosoft SQL Server Local DBInstancesProjects

also, I have v11.0 in

C:Users[My UserName]AppDataLocalMicrosoftMicrosoft SQL Server Local DBInstancesv11.0

I'm able to connect to v11.

What else can I try to reconnect to it?

The connection string is

 <add name="DefaultConnection"  connectionString="Data Source=(localdb)Projects;Initial Catalog=master;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False" providerName="System.Data.SqlClient" />

Edit

I tried Attaching the Db file to the connection string

AttachDbFileName=C:Users[My UserName]AppDataLocalMicrosoftMicrosoft SQL Server Local DBInstancesProjectsmaster.mdf;

However, I'm still not able to connect

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: 50 - Local Database Runtime error occurred. The specified LocalDB instance
does not exist.)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Seems like (localdb)Projects instance got deleted. You can either use (localdb)v11.0 or recreate Projects instance using SqlLocalDB utility

sqllocaldb c Projects 11.0

Command line explained

  • c - is for "create"
  • "Projects - is the instance name
  • 11.0 is the version

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...