question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EF 6.3 Add-Migration not working

See original GitHub issue

In our solution we have both EF and EF Core. EF is called only from full .NET projects and EF Core is called from a single .NET Core project. Up until upgrading to EF 6.3 we added migrations trough PMC. EntityFramework\add-migration -ConnectionStringName MyConnStringName -StartUpProjectName MyProject.Data -ProjectName MyProject.Data MIGRATIONNAME

After upgrade to EF 6.3 we get:

Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///..........\packages\EntityFramework.6.3.0\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. The system cannot find the file specified."
At ..........\packages\EntityFramework.6.2.0\tools\EntityFramework.psm1:782 char:5
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-P ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException
 
You cannot call a method on a null-valued expression.
At ..........\packages\EntityFramework.6.2.0\tools\EntityFramework.psm1:783 char:5
+     $dispatcher = $utilityAssembly.CreateInstance(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///..........\packages\EntityFramework.6.3.0\tools\EntityFramework.PowerShell.dll' or one of its dependencies. The system cannot find the file specified."
At ..........\packages\EntityFramework.6.2.0\tools\EntityFramework.psm1:811 char:5
+     $domain.CreateInstanceFrom(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException

App.Config of MyProject.Data:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  <section name="entityFramework"
    type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.3.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    requirePermission="false"/>
  </configSections>
  <connectionStrings>

      <add name="MyConnStringName" connectionString="Persist Security Info=True;Data Source=.;Initial Catalog=dev_db;Integrated Security=True"
        providerName="System.Data.SqlClient"/>
		
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0"/>
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
    </providers>
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.3.0.0"/>
      </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="System.ComponentModel.Annotations" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-4.2.1.0" newVersion="4.2.1.0"/>
        </dependentAssembly>
    </assemblyBinding>
  </runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>

I read that there is new ef6.exe instead of migrate.exe but I can’t find anything about how to use it.

Further technical details

EF version: 6.3 Database Provider: EntityFramework.SqlServer Operating system: Windows 10 IDE: Visual Studio 2019 16.3.0 Preview 4.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
bricelamcommented, Sep 24, 2019

The PowerShell module name has changed to EntityFramework6:

EntityFramework6\Add-Migration ...
8reactions
bricelamcommented, Sep 25, 2019

😅 Not documented; I didn’t think it would actually break anyone…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error while Add-Migration "Initialize" in .NET 6 Entity ...
You can resolve the problem by installing the specified framework and/or SDK. The specified framework can be found at:.
Read more >
The term 'Add-Migration' is not recognized as the name of a ...
Getting an error :Add-Migration : The term 'Add-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program ......
Read more >
entity framework - Why is there an Error in ef Add-Migration
I'm using: VS2019 CE EF 6.4.4 Now I understand why appears the follow message every time I started "enable-migrations" A version of Entity ......
Read more >
How to work with EF Core migrations in ASP.NET Core
To create a migration, you should use the Add-Migration command in the NuGet Package Manager. For example, to create a new migration called ......
Read more >
Atlantida; a Case Study in Household Sample Surveys
Should it prove not necessary to take account of the migration component by age and sex , the dif- ... 6.3 Mortality 6.31...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found