错误:50 - 发生本地数据库运行时错误。指定的 LocalDB 实例名称在 JETBRAIN RIDER 上无效

ben*_*ouf 1 c# sql-server asp.net-mvc rider

我正在尝试在 Jetbrain Rider 上编写 ASP.NET 核心,但尽管我配置了所有必要的设置以使用 SQL Server Express 2014,但我仍被此错误所困扰。

这是我的连接字符串:

"Server=(localdb)\\SQLEXPRESS;Database=Library;Trusted_Connection=True;MultipleActiveResultSets=True"
Run Code Online (Sandbox Code Playgroud)

我在 Microsoft SQL Management Studio 上成功连接了 SQLEXPRESS 实例

我还将我的连接字符串传递给了 startup.cs 的 OnConfiguring 方法中的 UseSQLServer 方法 optionsBuilder.UseSqlServer(@"Server=(localdb)\\SQLEXPRESS;Database=Library;Trusted_Connection=True;MultipleActiveResultSets=True");

我被这个错误困了 2 天,我阅读了几乎所有与 microsoft 和 Jetbrain 相关的文档,但无济于事

成功连接微软 SQL Management Studio

从命令行运行 dotnet ef database update 时遇到的错误

ben*_*ouf 5

Modifying my connection string as squillman suggested and removing one backslash solved my problem. Here is how the connection string looks like:

@"Data Source=abdullahi\SQLEXPRESS;Database=Library;Trusted_Connection=True;MultipleActiveResultSets=True"
Run Code Online (Sandbox Code Playgroud)

NOTE

  1. I changed Server to Data Source
  2. Changed the name of my instance and host to the actual SQL instance name and computer respectively.
  3. Removed the escape backslash character because the entire string is preceded by @