EF Migrations: Could not load file or assembly EntityFramework, Version=6.0.0.0

ef-migrations entity-framework-6 powershell

Question

I have been going round in circles trying to get EF to run my migrations via powershell, but getting no where. I can run them through visual studio, using the package manager console, but when I run it using a powershell script I get the error:

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)

The modified script I'm running (generated by octopus) is:

& "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

I have google'd this a lot and I know this is a common issue, so I have done the following checks:

EF version install via nuget is 6.1.3. This is the same across all of the package.config files in the solution, i.e.:

<package id="EntityFramework" version="6.1.3" targetFramework="net45" />

I have checked all the web and app configs and they are all consistent:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

This looks a bit odd to me, though I would assume that nuget would set this correctly? Either way, changing these values makes no difference.

I have checked there are no older versions of the ef lying around. The migrate.exe I'm using is the version from my packages folder that nuget downloaded and it states that it's version is 6.1.3-40302. I am running .net 4.5 which matches the packages config.

Any advice will be appreciated and I will try, maybe I'm missing something obvious.

1
0
9/23/2016 9:23:45 AM

Accepted Answer

So, I managed to fix this if anyone else has the same issue. The script from Octopus wasn't great, so I wrote it from scratch. The key issue for me at least was that the script needs to copy the migrate.exe into the folder where the TestApp.Data.dll is located and to execute it from there.

1
9/28/2016 10:50:44 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow