指定的LocalDb实例不存在

Rom*_*Mik 13 asp.net-mvc localdb

我已经使用名为'Projects'的localDB了一段时间了.这是默认情况下ASP.NET MVC 5项目创建的数据库.然而,突然它停止了,我无法连接到它,也没有重新启动它

SqlLocalDb start Projects
Run Code Online (Sandbox Code Playgroud)

我明白了

The specified LocalDB instance does not exist.
Run Code Online (Sandbox Code Playgroud)

我看到了文件夹

C:\Users\[My UserName]\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\Projects
Run Code Online (Sandbox Code Playgroud)

另外,我有v11.0 in

C:\Users\[My UserName]\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0
Run Code Online (Sandbox Code Playgroud)

我能够连接到v11.

我还可以尝试重新连接它吗?

连接字符串是

 <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" />
Run Code Online (Sandbox Code Playgroud)

编辑

我尝试将Db文件附加到连接字符串

AttachDbFileName=C:\Users\[My UserName]\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\Projects\master.mdf;
Run Code Online (Sandbox Code Playgroud)

但是,我仍然无法连接

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.)
Run Code Online (Sandbox Code Playgroud)

Mrc*_*ief 21

好像(localdb)\Projects实例被删除了.您可以使用SqlLocalDB实用程序来使用(localdb)\v11.0或重新创建Projects实例

sqllocaldb c Projects 11.0
Run Code Online (Sandbox Code Playgroud)

命令行解释

  • c - 用于"创造"
  • "项目 - 是实例名称
  • 11.0是版本