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

от admin

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.

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

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.

Читать:
Как распаковать cab файл

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.

Термин «добавление-миграция» не распознается как имя командлета.

Так случайным образом из одного дня в другой мои миграции перестали работать. Я добавляю перенос, и он говорит, что его не распознают. Я использую PM, так как это asp.net mvc и работал накануне.

add-migration: термин «add-migration» не распознается как имя командлета, функции, файла сценария или работающей программы. Проверьте написание имени или, если был включен путь, убедитесь, что путь правильный, и повторите попытку.

9 ответов

Это не совсем проблема OP, но, по крайней мере, для ядра dotnet, это также может быть вызвано отсутствием установленного пакета nuget Microsoft.EntityFrameworkCore.Tools , который используется для команд диспетчера пакетов в Visual Studio и command линия.

Что мне нужно было сделать .

1) Инструменты -> Диспетчер пакетов Nuget -> Настройки диспетчера пакетов

2) Вкладка Общие

3) Очистить все кеши NuGet

4) Перезапустите Visual Studio.

У меня была такая же проблема, и простое закрытие консоли диспетчера пакетов с последующим перезапуском Visual Studio исправило ее.

Я подозреваю, что ваш проект по умолчанию должен быть установлен, как упомянул Кирк Ларкин в комментариях. Щелкните раскрывающийся список проекта по умолчанию и укажите, в каком проекте у вас установлена ​​платформа entity framework.

enter image description here

Также эта ссылка может помочь, если раскрывающийся список вашего проекта по умолчанию не заполняется Раскрывающийся список проектов по умолчанию консоли диспетчера пакетов NuGet пуст

Надеюсь это поможет! Если нет, дайте мне знать, и я удалю ответ (мне пришлось использовать ответ, потому что я не могу комментировать менее 50 представителей) Ура!

Термин «Enable-Migrations» не распознается как имя командлета, функции, файла сценария или исполняемой программы.

Когда я ввожу эту команду: «Enable-Migrations» в консоли диспетчера пакетов, я получаю эту ошибку:

«Термин «Enable-Migrations» не распознается как имя командлета, функции, файла сценария или работающей программы. Проверьте правильность написания имени или, если был включен ap ath, убедитесь, что путь указан правильно, и повторите попытку. . В строке: 1 символ: 18 + Enable-Migrations <<<< + CategoryInfo: ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException»

Я использую VS2010 с EF 4.0, и я просто выполнял очень простой тестовый проект для развертывания веб-сайта с Windows Azure, но по какой-то причине я не могу включить миграцию.

У кого-нибудь есть идеи? Спасибо

задан 26 июн ’12, 08:06

Если это кому-то поможет: я должен был установить EF 4.3, чтобы включить миграцию. — Sandra Andonov

7 ответы

Попробуйте перезапустить Visual Studio. В моем случае помогло.

ответ дан 13 окт ’13, 22:10

Первым делом вам понадобится VS2010 Professional SP1.

После этого переустановите пакет приложения с помощью команды Install-Package EntityFramework -IncludePrerelease и это должно решить вашу проблему.

Если у вас установлена ​​последняя версия EntityFramework, а команда «Enable-Migrations» по-прежнему показывает ошибку переустановки/обновления NuGet, см. документацию: http://docs.nuget.org/docs/start-here/installing-nuget

ответ дан 18 мар ’13, в 20:03

Убедитесь, что у вас есть решение открыто. Я получил эту ошибку, потому что пытался запустить ее без открытия решения. Когда я открыл решение, оно работало нормально

ответ дан 07 мар ’13, в 15:03

Я работал над существующей кодовой базой, в которой уже была установлена ​​Entity Framework 5.x. Некоторые решения предлагают обновить до последней версии и запустить, но при установке последней версии удалить System.Data.Entity . Повторное добавление ссылки вызвало ошибки в моем старом коде, который использовал устаревшие API.

Решение запускается от имени администратора если вы уже установили фреймворк в своем решении

ответ дан 20 мар ’14, в 09:03

У меня была именно эта проблема, и я использовал старую версию NuGet, и мне помогло обновление NuGet через интерфейс расширений.

ответ дан 08 дек ’14, 13:12

«Install-Package EntityFramework» будет работать так же хорошо

Создан 16 июля ’12, 23:07

Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками azure entity-framework-migrations or задайте свой вопрос.

Похожие статьи