无法在VS2013终极中启用迁移

时间:2017-10-18 10:16:59

标签: c# asp.net-mvc entity-framework

In package Manager Console, I type `enable-migrations`,  The output shows error :

    PM> 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 pa
    th was included, verify that the path is correct and try again.
    At line:1 char:18
    + enable-migrations <<<< 
        + CategoryInfo          : ObjectNotFound: (enable-migrations:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

I also try to install

    PM> Install-Package EntityFramework -IncludePrerelease
    Install-Package : The current environment doesn't have a solution open.
    At line:1 char:16
    + Install-Package <<<<  EntityFramework -IncludePrerelease
        + CategoryInfo          : InvalidOperation: (:) [Install-Package], InvalidOperationException
        + FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.InstallPackageCommand

    PM> 

the problem still exist.

I am new to entity framework. Please help.

Thank you very much.

Cheers,
newbuntu


@TAHA SULTAN TEMURI, many thanks.  I use run as administrator and

Uninstall-Package EntityFramework -Force

结果是:

PM> Uninstall-Package EntityFramework -Force
Uninstall-Package : The current environment doesn't have a solution open.
At line:1 char:18
+ Uninstall-Package <<<<  EntityFramework -Force
    + CategoryInfo          : InvalidOperation: (:) [Uninstall-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.UninstallPackageCommand

PM> 

然后,我Install-Package EntityFramework

错误是:

PM> Uninstall-Package EntityFramework -Force
Uninstall-Package : The current environment doesn't have a solution open.
At line:1 char:18
+ Uninstall-Package <<<<  EntityFramework -Force
    + CategoryInfo          : InvalidOperation: (:) [Uninstall-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.UninstallPackageCommand

PM> Install-Package EntityFramework
Install-Package : The current environment doesn't have a solution open.
At line:1 char:16
+ Install-Package <<<<  EntityFramework
    + CategoryInfo          : InvalidOperation: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.InstallPackageCommand

PM> 

1 个答案:

答案 0 :(得分:0)

首先运行

  

Uninstall-Package EntityFramework -Force

然后

  

Install-Package EntityFramework

然后以管理员身份重新启动。