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

爷,独闯天下 提交于 2019-11-30 11:44:39
Elijah Lofgren

This is what worked for me to solve this issue:

Run:

Install-Package Microsoft.EntityFrameworkCore.Tools –Pre

In project.json add this (if not there already) to the "tools" section:

"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview4-final",

Useful reference: https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html

natemcmaster

As ErikEJ mentioned, there is no "enable-migrations". You will need to use "Add-Migrations" instead. See official docs for EF Core's Powershell commands here: http://docs.efproject.net/en/latest/cli/powershell.html

There appears to be a bug in NuGet and Package Manager Console in some versions of Visual Studio. If cmdlets are not recognized after adding the Commands package, try restarting VS.

Also, dnx commands will not be supported after RC1. New (forthcoming) dotnet tooling will be available for RC2. See https://github.com/aspnet/EntityFramework/issues/3925

The only way I managed to get EntityFrameworkCore.Tools (which includes Add-Migration) working with the latest EF Core & VS 2015 was to manually call the init script from the Package Manager Console like so:

PM> %UserProfile%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview1-final\tools\init.ps1

To add a new migration in EF7 use this command :

dnx ef migrations add YourMigrationUniqueName

There is no "enable-migrations" command in EF Core (EF7).

Just use "add-Migration"

Currently EF migrations are not supported out of the box:

https://github.com/aspnet/EntityFramework/issues/4497

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!