无法在Visual Studio 2015 Web API项目中启用EF6迁移

时间:2016-03-14 18:30:34

标签: c# visual-studio-2015 entity-framework-6 asp.net-core ef-migrations

在我的VS2015 ASP.NET 5 Web API项目中,我安装了EF6.1.3但是Package Manage控制台中的enable-migrations命令给出了以下错误:The term 'enable-migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. suggestions here没有一个工作我 - 给我同样的错误

更新

到目前为止,我已经尝试了以下命令并关闭/重新打开VS(即使是管理员):

Install-Package EntityFramework -IncludePrerelease

Update-Package –reinstall EntityFramework

Install-Package EntityFramework.Commands -Pre

3 个答案:

答案 0 :(得分:0)

您是否尝试过以下操作:

Install-Package EntityFramework -IncludePrerelease

我最近遇到了同样的问题。

答案 1 :(得分:0)

EntityFramework.Commands是为EF7设计的,与EF6不兼容。毫无疑问,“启用 - 迁移”缺失,因为这是not a command in EF7

您也可以尝试手动添加EF模块。所有nuget都可以导入命令,执行一个小的PowerShell文件。您可以通过手动查找和导入EntityFramework.psd1来自行完成此操作。见https://entityframework.codeplex.com/SourceControl/latest#src/NuGet/EntityFramework/tools/init.ps1

Do While rs_choice.EOF = False
    'add column1 in Choice
    '~Something~ = rs_choice.Fields("column1").Value
    rs_choice.MoveNext
Loop 

理论上NuGet应该在它打开的任何时候自动执行此操作,但是使用ASP.NET 5工具,项目模型已经改变,它们可能是VS中的nuget bug。你升级到最新的nuget工具(v3.3.0)了吗? https://dist.nuget.org/index.html

答案 2 :(得分:0)

我使用了此answer

中的解决方案

您需要再次卸载然后再安装EntityFramework。如果由于其他包使用的EntityFramework作为依赖项而导致卸载失败,请使用以下命令强制卸载过程。

  

Uninstall-Package -f EntityFramework