title: Trying to run EF Code first Migrate.exe tool on production environment failed
body: <p>I'm using EntityFramework version 6.1.3.</p>
  
  <p>I copied migrate.exe from EntityFramework version 6.1.3 package tool folder to bin folder of my website.</p>
  
  <p>My web site is compiled and published to production environment with x86 CPU and target framework 4.5.1</p>
  
  <p>I run the following command:</p>
  
  <blockquote>
    <p>D:\Sites\MatrixPortal\bin>migrate.exe
    d:\sites\MatrixPortal\bin\MatrixPortal.BL.dll
    /startUpDirectory="d:\Sites\MatrixPortal\bin"
    /startUpConfigurationFile="d:\Sites\MatrixPortal\Web.config"</p>
  </blockquote>
  
  <p>and i get the following error:</p>
  
  <blockquote>
    <p>ERROR: Could not load file or assembly
    'd:\sites\MatrixPortal\bin\MatrixPortal.BL' or one of its
    dependencies. The given assembly name or codebase was invalid.
    (Exception from HRESULT: 0x80131047)</p>
  </blockquote>
  
  <p>EDIT:</p>
  
  <p>when i try this:</p>
  
  <blockquote>
    <p>migrate MatrixPortal.BL.dll /verbose</p>
  </blockquote>
  
  <p>i get other error:</p>
  
  <blockquote>
    <p>System.BadImageFormatException: Could not load file or assembly
    'MatrixPortal.BL' or one of its dependencies. An attempt was made to
    load a program with an incorrect format. File name: 'MatrixPortal.BL' 
    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,
    String codeBase, Evidence assemblySecurity, RuntimeAssembly
    locationHint, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder,
    Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean
    suppressSecurityChecks)    at
    System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
    assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly,
    StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean
    throwOnFileNotFound, Boolean forIntrospection, Boolean
    suppressSecurityChecks)    at
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
    Evidence assemblySecurity, StackCrawlMark&amp; stackMark, IntPtr
    pPrivHostBinder, Boolean forIntrospection)    at
    System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
    Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean
    forIntrospection)    at System.Reflection.Assembly.Load(String
    assemblyString)    at
    System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.LoadAssembly(String
    name)    at
    System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindConfiguration()
    at
    System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run() 
    at System.AppDomain.DoCallBack(CrossAppDomainDelegate
    callBackDelegate)    at
    System.Data.Entity.Migrations.Console.Program.Run()    at
    System.Data.Entity.Migrations.Console.Program.Main(String[] args)</p>
    
    <p>=== Pre-bind state information === LOG: DisplayName = MatrixPortal.BL  (Partial) WRN: Partial binding information was supplied for an
    assembly: WRN: Assembly Name: MatrixPortal.BL | Domain ID: 2 WRN: A
    partial bind occurs when only part of the assembly display name is
    provided. WRN: This might result in the binder loading an incorrect
    assembly. WRN: It is recommended to provide a fully specified textual
    identity for the assembly, WRN: that consists of the simple name,
    version, culture, and public key token. WRN: See whitepaper
    <a href="http://go.microsoft.com/fwlink/?LinkId=109270" rel="nofollow">http://go.microsoft.com/fwlink/?LinkId=109270</a> for more information and
    common solutions to this issue. LOG: Appbase =
    file:///D:/Sites/MatrixPortal/bin/ LOG: Initial PrivatePath = NULL
    Calling assembly : EntityFramework, Version=6.0.0.0, Culture=neutral,
    PublicKeyToken=b77a5c561934e089.
    === LOG: This bind starts in default load context. LOG: Using application configuration file:
    C:\Users\guy_b\AppData\Local\Temp\tmpC402.tmp LOG: Using host
    configuration file:  LOG: Using machine configuration file from
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
    LOG: Policy not being applied to reference at this time (private,
    custom, partial, or location-based assembly bind). LOG: Attempting
    download of new URL
    file:///D:/Sites/MatrixPortal/bin/MatrixPortal.BL.DLL. ERR: Failed to
    complete setup of assembly (hr = 0x8007000b). Probing terminated.</p>
    
    <p>ERROR: Could not load file or assembly 'MatrixPortal.BL' or one of its
    dependencies. An attempt was made to load a program with an incorrect
    format.</p>
  </blockquote>
  
  <p>also tried this:
  <a href="http://www.azurefromthetrenches.com/command-line-entity-framework-code-first-migrations/" rel="nofollow">http://www.azurefromthetrenches.com/command-line-entity-framework-code-first-migrations/</a></p>
  
  <p>and created a file called Redirect.config with the following content:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /&gt;
                                  &lt;bindingRedirect oldVersion="0.0.0-6.1.3" newVersion="6.1.3" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>but got the same error as above :(</p>