EF 迁移:无法加载文件或程序集 EntityFramework,版本 =6.0.0.0
EF Migrations: Could not load file or assembly EntityFramework, Version=6.0.0.0
我一直在兜圈子,试图让 EF 通过 powershell 运行 我的迁移,但没有成功。我可以 运行 它们通过 visual studio,使用包管理器控制台,但是当我 运行 它使用 powershell 脚本时,我得到错误:
migrate.exe : At line:1 char:1
+ & "C:\Development\Ef\Tools\migrate.exe" "TestApp.Data.dll" /connect ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError Unhandled Exception: 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. at
System.Data.Entity.Migrations.Console.Resources.EntityRes..ctor()
at
System.Data.Entity.Migrations.Console.Resources.EntityRes.GetLoader()
at
System.Data.Entity.Migrations.Console.Resources.EntityRes.GetString(String
name, Object[] args) at
System.Data.Entity.Migrations.Console.Program.WriteError(String
message) at
System.Data.Entity.Migrations.Console.Program.Main(String[] args)
我运行ning(由章鱼生成)修改后的脚本是:
& "C:\Development\Ef\Tools\migrate.exe" "TestApp.Data.dll" /connectionProviderName="System.Data.SqlClient" /startupConfigurationFile="C:\Development\FeatureBranch\TestApp\TestApp.Root\TestApp.WebApi\web.config" /startUpDirectory="C:\Development\FeatureBranch\TestApp\TestApp.Root\TestApp.WebApi\bin" /Verbose
我经常遇到这种情况 google,我知道这是一个常见问题,所以我做了以下检查:
通过 nuget 安装的 EF 版本是 6.1.3。这在解决方案中的所有 package.config 文件中都是相同的,即:
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
我检查了所有的网络和应用程序配置,它们都是一致的:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
这对我来说有点奇怪,但我认为 nuget 会正确设置它?无论哪种方式,更改这些值都没有区别。
我检查过周围没有旧版本的 ef。我正在使用的 migrate.exe 是 nuget 下载的我的包文件夹中的版本,它声明它的版本是 6.1.3-40302。我是 运行ning .net 4.5,它与包配置相匹配。
任何建议将不胜感激,我会尝试,也许我遗漏了一些明显的东西。
所以,如果其他人遇到同样的问题,我设法解决了这个问题。 Octopus 的脚本不是很好,所以我从头开始编写。至少对我来说关键问题是脚本需要将 migrate.exe 复制到 TestApp.Data.dll 所在的文件夹并从那里执行它。
我一直在兜圈子,试图让 EF 通过 powershell 运行 我的迁移,但没有成功。我可以 运行 它们通过 visual studio,使用包管理器控制台,但是当我 运行 它使用 powershell 脚本时,我得到错误:
migrate.exe : At line:1 char:1 + & "C:\Development\Ef\Tools\migrate.exe" "TestApp.Data.dll" /connect ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError Unhandled Exception: 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. at System.Data.Entity.Migrations.Console.Resources.EntityRes..ctor()
at System.Data.Entity.Migrations.Console.Resources.EntityRes.GetLoader() at System.Data.Entity.Migrations.Console.Resources.EntityRes.GetString(String name, Object[] args) at System.Data.Entity.Migrations.Console.Program.WriteError(String message) at System.Data.Entity.Migrations.Console.Program.Main(String[] args)
我运行ning(由章鱼生成)修改后的脚本是:
& "C:\Development\Ef\Tools\migrate.exe" "TestApp.Data.dll" /connectionProviderName="System.Data.SqlClient" /startupConfigurationFile="C:\Development\FeatureBranch\TestApp\TestApp.Root\TestApp.WebApi\web.config" /startUpDirectory="C:\Development\FeatureBranch\TestApp\TestApp.Root\TestApp.WebApi\bin" /Verbose
我经常遇到这种情况 google,我知道这是一个常见问题,所以我做了以下检查:
通过 nuget 安装的 EF 版本是 6.1.3。这在解决方案中的所有 package.config 文件中都是相同的,即:
<package id="EntityFramework" version="6.1.3" targetFramework="net45" />
我检查了所有的网络和应用程序配置,它们都是一致的:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
这对我来说有点奇怪,但我认为 nuget 会正确设置它?无论哪种方式,更改这些值都没有区别。
我检查过周围没有旧版本的 ef。我正在使用的 migrate.exe 是 nuget 下载的我的包文件夹中的版本,它声明它的版本是 6.1.3-40302。我是 运行ning .net 4.5,它与包配置相匹配。
任何建议将不胜感激,我会尝试,也许我遗漏了一些明显的东西。
所以,如果其他人遇到同样的问题,我设法解决了这个问题。 Octopus 的脚本不是很好,所以我从头开始编写。至少对我来说关键问题是脚本需要将 migrate.exe 复制到 TestApp.Data.dll 所在的文件夹并从那里执行它。