迁移.exe无法加载entityframework。

11

我打算在构建服务器上设置迁移.exe之前,在本地使用它,但是我甚至无法运行帮助命令 /?而不出错。


System.IO.FileNotFoundException: Could not load file or assembly 
'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
or one of its dependencies. The system cannot find the file specified.

我一直在寻找解决方案,看到了Microsoft的migrate.exe入门页面(链接)等等,但是还没有解决这个问题。

我已经试过将migrate.exe文件复制到我的项目/bin/Debug文件夹中,与项目的dll和entity framework dll并列,但是我仍然看到这个错误(如下图所示)。

我还验证了entity framework dll的版本,它确实是6.0.0.0。我使用nuget来包含entity framework,并且当前正在使用 <package id="EntityFramework" version="6.1.3" targetFramework="net45" />

非常感谢任��建议或帮助!

证明我正在将migrate.exe文件复制到我的项目/bin/Debug目录中


大约在发布后10秒钟,我加载了一个独立的非VS PowerShell命令提示符并成功尝试了一下,因此似乎这可能是一个32/64位问题,带有误导性错误?如果是这样,有没有办法在VS中嵌入一个64位PS提示符? - JesseBuesking
1个回答

2

你是否使用了适用于你的.NET版本的正确EF程序集?

我的应用生成于.NET 4.5,因此我使用来自\packages\EntityFramework.6.1.0\lib\net45的程序集EntityFramework.dllEntityFramework.SqlServer.dll,以及来自\packages\EntityFramework.6.1.0\toolsmigrate.exe

尝试为startUpDirectorystartUpConfigurationFile参数使用绝对路径。

例如:

migrate.exe MyAssembly.dll /startUpDirectory="C:\MyApp\bin" /startUpConfigurationFile="C:\MyApp\App.config"

HTH


1
我遇到了类似的情况。这个答案启发我尝试将 EntityFramework.dll 和 EntityFramework.SqlServer.dll 从我的 bin\release 文件夹复制到与 migrate.exe 相同的路径中。这解决了核心问题,使得来自 package...\tools 目录的 migrate.exe 不再失败。 - sfuqua
1
这对我有用。我把migrate.exe放到我的bin目录中并在那里执行。没有问题。 - Yablargo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接