The term 'add-migration' is not recognized as the name of a cmdlet
It getting very annoying and I dunno so far what cases what but: every time I close Visual Studio 2015 and restart it opening same project again I can`t add migration with error
add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operab le program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again . At line:1 char:1
- add-migration 16072016
-
- CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException - FullyQualifiedErrorId : CommandNotFoundException
I have in tools "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
and in dependencies "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview2-final",
It every time.
Found
1 down vote
I had the same problem and found that it was a Visual Studio versioning problem in the Solution file.
I was targeting:
VisualStudioVersion = 14.0.25123.0
But I needed to target:
VisualStudioVersion = 14.0.25420.1
After making that change directly to the Solution file, EF Core cmdlets started working in the Package Manager Console.
No, problem still exi
Opening this issue again 'add-migration' is not recognized as the name of a cmdlet is a very annoying bug and I facing it once in a day or two. And I still do not understand what causes this issue. Some random play with reopening studio and other things suddenly resoles issue but I cannot catch what exactly.
PS VisualStudioVersion = 14.0.25431.01 - same as studio
error itself
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. At line:1 char:1
- add-migration
-
- CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException - FullyQualifiedErrorId : CommandNotFoundException
Today again
add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelli ng of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
- add-migration
-
- CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException - FullyQualifiedErrorId : CommandNotFoundException
Now again. So frustrating. Happens once I restart comp. As I do it not often (usually sent it to hibernation) with error coming again I forgetting how I solved it. Every time it just standard restart reset clean project rebuild all things.
PM> add-migration jobs -Verbose add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or opera ble program. Check the spelling of the name, or if a path was included, verify that the path is correct and try aga in. At line:1 char:1
- add-migration jobs -Verbose
-
- CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException - FullyQualifiedErrorId : CommandNotFoundException
And again today. Can somebody kill this issue?
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. At line:1 char:1
- add-migration
-
+ CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Now version in solution file matches studio version. But I cannot made migration
again today.
So so annoying
add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check th e spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
- add-migration usertracking
-
+ CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Try the following steps:
-
Remove all Microsoft.EntityFrameworkCore.Tools references from dependencies and tools sections inside a project.json
-
Close Package Manager Console (PMC) and restart Visual Studio
-
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
- Open the PMC and type
Add-Migration $Your_First_Migration_Name$ That's because the PMC recognize the tools when Visual Studio is starting.
So I don't have a project.json file, but csproj, and I removed it and added it manually to csproj and that solved my issue, but is this a permanent fix, or will this issue start to come back again, as it has before?
I commented out the original contents of my .csproj file and pasted the following:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
Using this code, and restarting VS, Add-Migration {migrationName} works for me now.
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
new content of .csproj file
If you are interested in knowing how migrations work with .NET Core read this: https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/migrations
I don't think that the original Add-Migration PowerShell scripts are supported with .NET Core.
If you guys have a problem with migrations, please open another issue. This is getting confusing who is answering to what question.
Should this be closed?
cc: @Eilon @rowanmiller
cc @divega / @ajcvickers / @bricelam
is this a permanent fix, or will this issue start to come back again
Manually adding the DotNetCliToolReference is the only way to use the package. (until we get NuGet/Home#4190)
I don't think that the original Add-Migration PowerShell scripts are supported with .NET Core.
They are, and they're recommended if you're using Visual Studio since they provide a more integrated experience. (e.g. detecting your startup project, opening newly created files, etc.)
@bricelam Any possibilities to add them to the doc? I haven't seen them anywhere. :confused:
They're buried somewhere inside the EF Docs: https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell
Also mentioned in EF's getting started docs. E.g. https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db
Am also having these issues am using VS 2013 and EF 6,pls help