1

我像这样运行 Add-Migration

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 (azure btw) 时,它就可以工作了。这次没有这样的运气。我试过重新启动,关闭防火墙等。没有运气。

不太理想的是,我们是两个使用同一个数据库的开发人员,所以有时一个人会更新它并创建一个不匹配的问题,但它仍然不应该以这种方式连接失败,所以这无关紧要。

编辑:我的连接字符串是:

<add name="ViducationConnection" connectionString="Server=tcp:v6u2f4fbbg.database.windows.net,1433;Database=vidutesAqx321gza;User ID=myuser@v6u2f4fbbg;Password=mypassword;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
4

1 回答 1

0

好吧,似乎一夜之间我的视觉决定停止收听 -ConnectionStringName

因为当我进入 app.config 并添加完全相同的连接字符串但使用我的 dbcontext 名称时,它立即起作用。

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

于 2013-06-25T15:01:32.443 回答