efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Unable to Run Add-Migration Command in VS2017 RC2

Open danwalmsley opened this issue 9 years ago • 5 comments

The is a .net 4.6.1 class library project.

I run

PM> Add-Migration Initial
Cannot execute this command because Microsoft.EntityFrameworkCore.Design is not installed. Install the version of that package that matches the installed version of Microsoft.EntityFrameworkCore and try again.

Even though Microsoft.EntityFrameworkCore.Design is installed!

Any ideas?

packages.config

<package id="Microsoft.AspNetCore.Hosting.Abstractions" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Http.Abstractions" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.AspNetCore.Http.Features" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.Data.Sqlite" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Design" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Relational" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Relational.Design" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Sqlite" version="1.1.0" targetFramework="net461" />
  <package id="Microsoft.EntityFrameworkCore.Tools" version="1.1.0-preview4-final" targetFramework="net461" developmentDependency="true" />

I found that (as setting the solutions default project to the class library made it work) even though I had selected my class library in the package manager console.

Perhaps a bug in visual studio?

danwalmsley avatar Jan 03 '17 22:01 danwalmsley

Stupid question for you: did you dotnet restore before trying the add migration?

JDunaganFL avatar Jan 04 '17 15:01 JDunaganFL

Does adding -Verbose give any additional information? If not, could you share your project with us so we can investigate further?

bricelam avatar Jan 04 '17 17:01 bricelam

I was having the same issues where EF components were not found. Try doing a cd to the project directory (where the VS Project file is) before running the command.

ie:

cd C:\MyDevFolder\ProjectFolder
Add-Migration Initial

if you have more than one Context, be sure to specify it with: Add-Migration Initial --context MyDbContext

asleight avatar Jan 09 '17 21:01 asleight

In case you can try the latest version of the tooling, here are some instructions: #7358.

divega avatar Jan 13 '17 23:01 divega

EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.

BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

rowanmiller avatar Jan 27 '17 19:01 rowanmiller