Имя add migration не распознано как имя командлета
Перейти к содержимому

Имя add migration не распознано как имя командлета

  • автор:

Why add-migration is not recognized?

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.

+ CategoryInfo : ObjectNotFound: (Add-Migration:String) [], CommandNotFoundException

Answer

Install Microsoft.EntityFrameworkCore.Tools menually as given below

Right click on your project name which project want add reference Microsoft.EntityFrameworkCore.Tools.

Another way

i.Open your project.json file and Remove all Microsoft.EntityFrameworkCore.Tools references from dependencies and tools sections.

ii.Colse Package Manager Console and and restart your Visual Studio 2017,2019 etc.

iii.Add this code as given below

iv.Add under tools section

v. Restart again Visual Studio 2017,2019 etc.

vi.Open the PMC(Package Manager Console) and type

Changed the entry in tools to

And then run dotnet restore. After the restore was completed, Add-Migration worked normally. I hope you will do it.

Another Example

The error «The term ‘Add-Migration’ is not recognized» typically occurs when running the dotnet ef command in the package manager console in Visual Studio. It means that the command Add-Migration is not recognized by the package manager console.

This issue can occur when the package manager console is not set to the correct project or the Entity Framework Core tools are not installed. To resolve this issue, you can try the following steps:

This issue can occur when the package manager console is not set to the correct project or the Entity Framework Core tools are not installed. To resolve this issue, you can try the following steps:

  1. In the package manager console, make sure the default project is set to the project that contains your data context. You can check this by running the command get-project and verifying that the correct project is displayed.
  2. Ensure that the Entity Framework Core tools are installed in the project. You can check this by looking at the project’s dependencies in the project file (*.csprojensuringensure that the package Microsoft.EntityFrameworkCore.Design is included.
  3. Make sure that you have the latest version of the EF Core tools by running the command dotnet tool update —global dotnet-ef
  4. Close and reopen the package manager console and try running the command again.

If the problem still persist, Please make sure that the project that you are trying to run the command on is an ASP.NET Core project, as the dotnet ef command is specific to ASP.NET Core projects.

Related information

Sundar Neupane

Sundar Neupane

I like working on projects with a team that cares about creating beautiful and usable interfaces.

The term 'add-migration' is not recognized as the name of a cmdlet

So randomly from one day to the next my migrations stopped working. I do add-migration and it says its not being recognized. I’m using PM since this is a asp.net mvc and was working the day before.

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.

add-migration : The term ‘add-migration’ is not recognized…

I’m getting to grips with EF.Core, never having used it before I find it has a few quirks that I’m not used to. The first of these is the concept of a migration. I was trying to set up an initial migration and got the error in the nuget package manager console —

Fortunately for me the resolution was trivial, all I needed to do was to add the relevant version of Microsoft.EntityFrameworkCore.Tools to my application and everything worked as expected

Written by Steve Ellwood

Senior Integrations Officer at Doncaster Council Any views expressed are entirely my own.

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The term ‘add-migration’ is not recognized as the name of a cmdlet #1674

The term ‘add-migration’ is not recognized as the name of a cmdlet #1674

Comments

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

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»,

The text was updated successfully, but these errors were encountered:

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

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

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

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

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

Now version in solution file matches studio version. But I cannot made migration

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

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

  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.

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:

netcoreapp1.0 $(PackageTargetFallback);dotnet5.6;portable-net45+win8 false false false

Using this code, and restarting VS, Add-Migration works for me now.

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.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *