Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法运行启用迁移VS2013 SP4_C#_Asp.net Mvc_Entity Framework_Nuget_Entity Framework Migrations - Fatal编程技术网

C# 无法运行启用迁移VS2013 SP4

C# 无法运行启用迁移VS2013 SP4,c#,asp.net-mvc,entity-framework,nuget,entity-framework-migrations,C#,Asp.net Mvc,Entity Framework,Nuget,Entity Framework Migrations,我正在使用VS2013社区版SP4创建一个MVC 5网站。它使用EntityFramework v6。我正在尝试通过添加一个辅助表来保存其他数据来扩展默认的AspNetUsers数据库,但是,当我尝试运行启用迁移时,出现以下错误: Enable-Migration : The term 'Enable-Migration' is not recognized as the name of a cmdlet, function, script file, or operable program.

我正在使用VS2013社区版SP4创建一个MVC 5网站。它使用EntityFramework v6。我正在尝试通过添加一个辅助表来保存其他数据来扩展默认的AspNetUsers数据库,但是,当我尝试运行
启用迁移时,
出现以下错误:

Enable-Migration : The term 'Enable-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
+ Enable-Migration
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Enable-Migration:String) [], 
                              CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
我尝试了谷歌搜索建议的以下补救措施:

  • 打开解决方案
  • 清洗和重建溶液
  • 重新启动VS2013
  • 卸下和重新安装NuGet
  • 运行
    Install Package EntityFramework-IncludePrerelease
    命令
  • 确保VS2013以管理员身份运行
还有什么我可以试试的吗


谢谢

正确的术语是
启用迁移

这里还有一些其他有用的信息,是从我对一个类似问题的回答中粘贴出来的

add-migration InitialCreate
这将创建一个迁移。InitialCreate实际上是一个字符串,您可以将其更改为任何您想要的内容。此命令将生成从strach创建数据库所需的脚本

update-database
此命令验证数据库并应用所需的迁移(或多个迁移-可能有多个),以使数据库保持最新

这是初始设置。如果您对第一个code first类做了进一步的更改,或者添加了更多,那么您只需要添加一个新的迁移,然后执行它

add-migration AddedFirstName
update-database
就这么简单

还有一些更高级的概念,如种子、回滚、特定迁移的更新等,但我上面键入的内容涵盖了迁移的基础知识和日常使用


我建议您阅读这篇文章,它详细地解释了一切:

回答得好!回答了问题并提供了额外的细节:)