【问题标题】:CommandNotFoundException in asp.net mvc 5 database migrationasp.net mvc 5 数据库迁移中的 CommandNotFoundException
【发布时间】:2017-12-15 09:11:52
【问题描述】:

我尝试运行这个命令:

Enable-Migrations -ContextType ApplicationDbContext

得到这个异常:

Enable-Migrations : The term 'Enable-Migrations' 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-Migrations -ContextType ApplicationDbContext
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我正在使用 vs 2015 社区版。重新启动并以管理员身份运行无法解决问题。如果我尝试运行此命令来重新安装实体框架:

Install-Package EntityFramework -IncludePrerelease

也得到这个异常:

Install-Package : An error occurred while retrieving package metadata for 'Newtonsoft.Json.10.0.3' from source 'C:\Path\packages'.
At line:1 char:1
+ Install-Package EntityFramework -IncludePrerelease
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

请给我任何解决方案。

【问题讨论】:

    标签: asp.net asp.net-mvc entity-framework ef-code-first entity-framework-migrations


    【解决方案1】:

    区分大小写

    enable-migrations -contexttypename DBCONTEXT
    

    您还可以从

    中查看可用选项
    get-help EntityFramework
    

    【讨论】:

    • 它没有解决问题。同样的错误显示@Rahul
    猜你喜欢
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    • 2015-01-04
    • 1970-01-01
    • 2022-01-21
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    相关资源
    最近更新 更多