gpt4 book ai didi

c# - 无法使用 migrate.exe 运行代码优先迁移

转载 作者:可可西里 更新时间:2023-11-01 03:14:06 25 4
gpt4 key购买 nike

我正在尝试更新测试系统上的数据库。当我运行 update-database在 visual studio 中,事情按预期工作。

当我部署然后尝试在测试机器上运行时:

Migrate.exe CodeFirst.dll /startupConfigurationFile="..\web.config"

我得到:

no connection string named xxx could be found in the application config file

...即使在 web.config 中有一个具有该名称的连接字符串。只有一个 .config 文件,没有我正在运行的 dll 的配置文件

我试图手动声明我的连接字符串:

Migrate.exe CodeFirst.dll /connectionString="Data Source=192.168...;Initial Catalog=Database;" /connectionProviderName="System.Data.SqlClient"

但由于某种原因仍然给出相同的错误...它是否忽略了我传入的连接字符串并试图再次寻找一个?为什么要这样做?

但这给了我一个非常奇怪的错误:

The migrations configurations type "Source=192.168... could not be found in the assembly CodeFirst.dll I wondered if it had something to do with spaces, so I tried changing 'data source' to 'server' and Initial Catalog to 'database' but that didn't help.

编辑:固定引号

我见过类似的问题,但它们都是关于在 visual studio 中运行的,我在尝试这样做时没有遇到任何问题。关于我能做什么的更多想法?有没有人得到这些选项中的任何一个?

最佳答案

终于让它与 Entity Framework 6.1.3 一起工作。我不确定版本是否真的很重要,但我们最终下载了代码并针对它进行了调试。

真正不同的是在所需的两个路径中都使用了完整路径......希望可以帮助别人!

migrate CodeFirst.dll Configuration /startUpDirectory:"C:\src\app\CodeFirst\bin\Debug" /startUpConfigurationFile:"C:\src\app\CodeFirst\bin\CodeFirst.dll.config" 

我联系了 EF 团队,显然 EF7 中的情况会更好:https://github.com/aspnet/EntityFramework/issues/2974

关于c# - 无法使用 migrate.exe 运行代码优先迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28724546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com