2015-03-03 105 views
1

我不斷收到此錯誤的LocalDB當我嘗試在包管理器控制檯做一個更新的數據庫命令:無法連接在Visual Studio

ClientConnectionId:00000000-0000-0000-0000-000000000000 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. Specified LocalDB instance name is invalid. )

我的連接字符串是:

<connectionStrings> 
    <add name="BookServiceContext" connectionString="Data Source=(localdb)\\v11.0; Initial Catalog=BookServiceContext-20150228232739; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|BookServiceContext-20150228232739.mdf" providerName="System.Data.SqlClient" /> 
</connectionStrings> 

我可以通過SSMS 2014連接,我可以在SQL Server對象資源管理器中看到(localdb)\MSSQLLocalDB(localdb)\ProjectsV12

編輯

即使在連接字符串的一部分被改爲: AttachDbFilename = | DataDirectory目錄| \ BookServiceContext-20150228232739.mdf」

它仍然拉動了同樣的錯誤

回答

0

有在您連接字符串反斜槓丟失:中

代替

AttachDbFilename=|DataDirectory|BookServiceContext-20150228232739.mdf" 

應該

AttachDbFilename=|DataDirectory|\BookServiceContext-20150228232739.mdf" 

參考Creating a Connection String and Working with SQL Server LocalDB

更新

事實證明,經過\沒有失蹤,但有太多的人。我能夠加入到重現錯誤另一個\

Data Source=(localdb)\\v11.0 

這意味着你Data Source應該是:

Data Source=(localdb)\v11.0 

只有一個\

+0

隨着上述變化,但還是去拉一樣錯誤。連接字符串在Visual Studio中自動生成。 – 2015-03-03 06:30:53

+0

查看我的更新回答。也許它仍然會有所幫助: - ] – t3chb0t 2015-08-10 16:07:07