3

安裝以下軟件包後:爲什麼add-migration命令未創建遷移?不承認包

"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0""Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"(-Pre)

當運行add-migration "InitialCreate"命令,我收到以下錯誤:

Cannot execute this command because Microsoft.EntityFrameworkCore.Design is not installed. Install the version of that package that matches the installed version of Microsoft.EntityFrameworkCore and try again.不過,如果你看一下在下面的.json文件中,您會看到軟件包是匹配的,所以這個錯誤信息與我矛盾。

這是我project.json文件:

{ 
    "runtimes": { 
    "win10-x64": {} 
    }, 

    "dependencies": { 
    "Microsoft.AspNetCore.Diagnostics": "1.1.0", 
    "Microsoft.AspNetCore.Mvc": "1.1.0", 
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", 
    "Microsoft.AspNetCore.StaticFiles": "1.1.0", 
    "Microsoft.EntityFrameworkCore": "1.1.0", 
    "Microsoft.EntityFrameworkCore.Design": "1.1.0", 
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0", 
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final", 
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0", 
    "Microsoft.Extensions.Configuration.Json": "1.1.0", 
    "Microsoft.Extensions.Logging.Console": "1.1.0", 
    "Microsoft.NETCore.App": "1.1.0" 
    }, 

    "tools": { 
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", 
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final" 
    }, 

    "frameworks": { 
    "netcoreapp1.0": { 
     "imports": [ 
     "dotnet5.6", 
     "portable-net45+win8" 
     ] 
    } 
    }, 

    "buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
    }, 

    "runtimeOptions": { 
    "configProperties": { 
     "System.GC.Server": true 
    } 
    }, 

    "publishOptions": { 
    "include": [ 
     "wwwroot", 
     "web.config" 
    ] 
    }, 

    "scripts": { 
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] 
    } 
} 

回答

2

你需要改變你的project.json,如下圖所示。

注:需要包括"type": "platform"

{ 
    "dependencies": { 
    "Microsoft.NETCore.App": { 
     "version": "1.0.1", 
     "type": "platform" 
    } 
    } 
} 

你可以閱讀更多關於這個問題在這裏:GitHub

1

如果您在您的解決方案多個項目。 使用-projectname選擇合適的項目,這樣

附加遷移InitialCreate -ProjectName mydbProject

與您的項目名稱替換mydbProject

相關問題