简体   繁体   中英

How do I Enable Migrations in the Package Manager Console?

I'm trying to enable migrations in MVC4, Entity Framework 5.00, however when I input the command it throws the following error:

Cannot determine a valid start-up project. Using project 'EFMigrations' instead. Your configuration file and working directory may not be set as expected. Use the -StartUpProjectName parameter to set one explicitly. Use the -Verbose switch for more information.
    Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file://\\s01\data\Documents\Visual Studio 2010\Projects\EFMigrations\packages\EntityFramework.5.0.0\tool
    s\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)"
    At \\s01\data\Documents\Visual Studio 2010\Projects\EFMigrations\packages\EntityFramework.6.0.0-beta1\tools\EntityFramework.psm1:669 char:62
    +     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $ToolsPath EntityFramework.PowerShell.Utility.dll))
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    You cannot call a method on a null-valued expression.
    At \\s01\data\Documents\Visual Studio 2010\Projects\EFMigrations\packages\EntityFramework.6.0.0-beta1\tools\EntityFramework.psm1:670 char:50
    +     $dispatcher = $utilityAssembly.CreateInstance <<<< (
        + CategoryInfo          : InvalidOperation: (CreateInstance:String) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file://\\s01\data\Documents\Visual Studio 2010\Projects\EFMigrations\packages\EntityFramework.
    5.0.0\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)"
    At \\s01\data\Documents\Visual Studio 2010\Projects\EFMigrations\packages\EntityFramework.6.0.0-beta1\tools\EntityFramework.psm1:698 char:31
    +     $domain.CreateInstanceFrom <<<< (
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

any and all help would be appreciated.

Running migrations from a network path is unsupported.

EF Team Triage: The migrations commands require full trust to run. Because you are running from a network share it looks like you are running in a lower trust level. In the past we have made the decision that the migrations commands would require full trust because it reduces the complexity of the implementation.

http://entityframework.codeplex.com/workitem/856

This means you have to put your project on a local drive, then you'll be able to run migrations.

事实证明@Stijn的答案的确正确,但是并不能解决问题,解决方案是简单地将整个项目复制并粘贴到硬盘中,命令将起作用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM