efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Add-Migrations not working in Visual Studio 2015

Open jonswaino opened this issue 10 years ago • 12 comments

Current listing of EF packages in my project:

Id Versions ProjectName


EntityFramework.Core {7.0.0-rc1-final}
EntityFramework.MicrosoftSqlServer {7.0.0-rc1-final}
EntityFramework.Commands {7.0.0-rc1-final}

Yet when I try to add migrations in PowerShell using add-migration I get the following error: add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I've tried restarting visual studio/rebooting to no avail.

jonswaino avatar Feb 04 '16 23:02 jonswaino

Can you provide a few more details? What kind of project are you using? Did nuget restore work correctly? Which version of Windows are you using?

natemcmaster avatar Feb 04 '16 23:02 natemcmaster

OS: Windows 10 Framework: dnx451 VS: Visual Studio 2015 Communitiy Edition. Solution: Regular Class library

jonswaino avatar Feb 08 '16 20:02 jonswaino

Xproj does currently not support commands in Package Manager Console. To use migrations, you need to use the command line - https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html#create-your-database.

Xproj has enabled support for the upcoming RC2 release, so you'll be able to use the commands when that is available.

rowanmiller avatar Feb 12 '16 18:02 rowanmiller

Hi, If you have received error like “the term ‘Add-Migration’ is not recognized as the name of a cmdlet, then close and reopen the visual studio.

After reopen the Visual Studio -> Open Package Manager Console Type Update-Database and Enter

santhakumar11 avatar Oct 10 '16 03:10 santhakumar11

I had similar issues in VS 2013. What I did was to update my Package Manager Console, restarted VS and that fixed it for me.

sunnyokoro avatar Oct 21 '16 04:10 sunnyokoro

Mine was working 2 days ago, now it's giving the "not recognized as name cmdlet, function ..." Error.

twisstosin avatar Nov 04 '16 13:11 twisstosin

I had the same issue. I ran VS2015 as Administrator and it solved my issue

willwhite1964 avatar Mar 08 '17 11:03 willwhite1964

Try the following steps:

  1. Remove all Microsoft.EntityFrameworkCore.Tools references from dependencies and tools sections inside a project.json

  2. Close Package Manager Console (PMC) and restart Visual Studio

  3. Add under dependencies section:

"Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview2-final", "type": "build" } 4) Add under tools section

"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" 5) Restart again Visual Studio 2015

  1. Open the PMC and type

Add-Migration $Your_First_Migration_Name$ That's because the PMC recognize the tools when Visual Studio is starting.

Padmanaabhah avatar Jun 16 '17 13:06 Padmanaabhah

In VS2017 same thing... RUN AS ADMINISTRATOR! 🗡

AdrianPT avatar Feb 16 '18 18:02 AdrianPT

Hi, i'm trying to use the command enable-migration, but i am experiencing always the same error: The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. I tried all the possible solutions that you have proposed; no one of these solution worked. i'm using VS2019

NanuNic9379 avatar Apr 08 '20 19:04 NanuNic9379

@NanuNic9379 The above thread is quite old. You don't need Enable-Migrations any more. See e.g. https://stackoverflow.com/questions/41403824/cant-enable-migrations-for-entity-framework-on-vs-2017-net-core

Note: as mentioned in the above you will need to install the Microsoft.EntityFrameworkCore.Tools package.

If you still can't use the other PowerShell commands, e.g. Add-Migration, try opening a new issue.

lajones avatar Apr 08 '20 23:04 lajones

Eu tive o mesmo problema, eu estava usando o PowerShell para o comando, mas ele funciona no console do gerenciador de pacotes.

Tente rodar em -> Ferramentas -> Gerenciador de Pacotes NuGet -> Console do Gerenciador de Pacotes

KnightYan avatar Mar 14 '22 14:03 KnightYan