当我尝试在EF 4.3.1中启用迁移时引发异常

Rud*_*cek 11 entity-framework entity-framework-4 ef-migrations

我在我的.Net 4.0类库项目中使用nuget安装的Entity framework 4.3.1.在情况下,当我在PM控制台中调用"Enable-Migrations"命令时,我收到以下异常:

用"1"参数调用"LoadFrom"的异常:"Nelzenačístsumbornebosestavenífile:/// D:\ Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages\EntityFramework.4.3.1\to ols\EntityFramework.PowerShell.Utility.dll nebo jeden zjejichzávislýchprvků.Systémnemůženaléztuvedenýsubbor." 在D:\ Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages\EntityFramework.5.0.0-rc\tools\EntityFramework.psm1:393 char:62 + $ utilityAssembly = [System.Reflection.Assembly] :: LoadFrom <<<<((Join-Path $ toolsPath Entity Framework.PowerShell.Utility.dll))+ CategoryInfo:NotSpecified:(:) [],MethodInvocationException + FullyQualifiedErrorId:DotNetMethodException

您无法在空值表达式上调用方法.在D:\ Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages\EntityFramework.5.0.0-rc\tools\EntityFramework.psm1:394 char:50 + $ dispatcher = $ utilityAssembly.CreateInstance <<<<(+ CategoryInfo:InvalidOperation:(CreateInstance:String)[],RuntimeException + FullyQualifiedErrorId:InvokeMethodOnNull

使用"8"参数调用"CreateInstanceFrom"的异常:"Typ System.Data.Entity.Migrations.En ableMigrationsCommandzesestaveníEntityFramework.PowerShell,Version = 4.3.1.0,Culture = neutral,P ublicKeyToken = b77a5c561934e089nelzenačíst." 在D:\ Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages\EntityFramework.5.0.0-rc\tools\EntityFramework.psm1:418 char:31> + $ domain.CreateInstanceFrom <<<<(+ CategoryInfo:NotSpecified:(:) [],MethodInvocationException + FullyQualifiedErrorId:DotNetMethodException

Rud*_*cek 25

我解决了上述问题.

  1. 我使用NuGet包管理器卸载了Entity框架.
  2. 我手动清除了在packages目录中以"Entity"开头的子目录.
  3. 我再次安装了Entity Framework 4.3.1

现在正确启用了迁移.