I'm using Entity framework 4.3.1 installed by nuget in my .Net 4.0 class library project. In situation, when I call the "Enable-Migrations" command in PM console, I receive following exception:
Exception calling "LoadFrom" with "1" argument(s): "Nelze načíst soubor nebo sestavení file:///D:\ Users\DvoracekR\Documents\Visual Studio 2010\Projects\WebCameras\packages\EntityFramework.4.3.1\to ols\EntityFramework.PowerShell.Utility.dll nebo jeden z jejich závislých prvků. Systém nemůže nalé zt uvedený soubor." At 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
You cannot call a method on a null-valued expression. At 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
Exception calling "CreateInstanceFrom" with "8" argument(s): "Typ System.Data.Entity.Migrations.En ableMigrationsCommand ze sestavení EntityFramework.PowerShell, Version=4.3.1.0, Culture=neutral, P ublicKeyToken=b77a5c561934e089 nelze načíst." At 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
I solved problem described above.
Now migrations are enabled correctly.
I know this is an old question and already has an accepted answer, but I had this issue and thought I'd share what I did to resolve it.
My solution was in source control and I had messed up my local project. I decided to start over from Source Control, so I created a new folder and Checked out the code from SVN.
When I did, I was no longer able to create migrations. I got the same error listed above. I tried Uninstall-Package EntityFramework
, but got a similar message about missing files/references within EntityFramework.
I went back to my old folder and looked in $Project\packages\EntityFramework.6.0.2\
and compared this to my new folder. There were several DLLs/Xml files missing because they were not in Source Control. They were in the \tools\
, \lib\net40
and \lib\net45\
directories.
I just copied these files to my new project, closed/reopened Visual Studio, and did a Rebuild. After that, everything was working fine.
Reinstalling the NuGet package didn't work for me. What did work was to move the project from a network drive to a local drive. Running a compare showed that, apart from obj
and bin
directories, all files were binary identical.
If I remember correctly, my last attempt at Update-Database
was before I moved the project to a network drive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With