2013-06-25 52 views
1

我運行Add-遷移像這樣的Visual Studio包管理器控制檯遷移拒絕使用連接字符串

PM> Add-Migration -ConnectionStringName "ViducationConnection" -Verbose -StartUpProjectName "Viducate.Domain" 

而這就是我得到:

cmdlet Add-Migration at command pipeline position 1 
Supply values for the following parameters: 
Name: myoj 
Using StartUp project 'Viducate.Domain'. 
Using NuGet project 'Viducate.Domain'. 
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct. ---> System.Data.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. ---> System.Data.SqlClient.SqlException: 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) 

現在這裏奇怪的是,如果我運行它的工程,我檢查了連接字符串,它的工作原理(也沒有改變)。 這個工作之前就這樣沒有任何改變連接明智

無論我給連接字符串什麼名字它失敗相同,我可以給它正確的名稱或「無論」它以完全相同的方式失敗。 讓我覺得它沒有找到連接字符串。

但它的存在,無論是在我的主項目的web.config以及在Vidcate.Domain項目的app.config。

而這已經工作過。然而,我又一次遇到了這個問題,但是那次當我從visual studio sql server對象瀏覽器瀏覽sql server(天藍色的btw)時,它就工作了。這次沒有這樣的運氣。我試過重新啓動,關閉防火牆等,沒有運氣。

不甚理想

我們是兩個開發人員提供相同的DB工作,所以有時一個更新,並創建一個不匹配,但仍然不應該不以這種方式連接,因此不應該的問題。

編輯:我的連接字符串是:

<add name="ViducationConnection" connectionString="Server=tcp:v6u2f4fbbg.database.windows.net,1433;Database=vidutesAqx321gza;User [email protected];Password=mypassword;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" /> 
+0

您是否啓用了IP訪問Azure數據庫?我懷疑這是問題 –

+0

是的,我只是雙重檢查,我的IP沒有改變。我應該提到,我可以使用SQL Server Management Studio和Visual Studio SQL Server對象資源管理器,並且我可以採用確切的連接字符串並將它從Microsoft提供給ConnMaker.exe,並且它可以工作。所以這只是從包管理器控制檯 –

+0

我應該還提到,這已經工作過。我曾經遇到這個錯誤,然後它隨機消失。 –

回答

0

好了,似乎一夜之間我的視覺乾脆決定停止監聽-ConnectionStringName

因爲當我進入的app.config並添加完全相同的連接字符串,但與我的dbcontext它的名字馬上工作。

所以使用自定義連接字符串,只是停止工作。

+0

但是,當我嘗試更新localdb(用於單元測試)時,它再次偵聽ConnectionStringName。這確實很奇怪。但至少現在起作用了。 –

相關問題