實體框架核心 - 無法添加第一次遷移

entity-framework-core visual-studio-2015

我正在嘗試創建我在Visual Studio 2015中開發的ASP.Net Core項目的第一次遷移。我的解決方案只有一個Project。我的project.json文件位於Project文件夾的根目錄中。

我右鍵單擊項目並選擇“打開命令行>默認”並輸入以下內容:

dotnet ef migrations add InitialDatabase

命令行返回:

No project was found. Change the current working directory or use the --project option.

我嘗試了所有不同版本的EntityFrameworkCore和Tools。我的project.json文件如下:

{
  "dependencies": {
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.1",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.1",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.1",
    "Microsoft.EntityFrameworkCore": "1.0.2",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.2",
    "Microsoft.EntityFrameworkCore.Design": {
      "type": "build",
      "version": "1.0.2" 
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "type": "build",
      "version": "1.0.0-msbuild3-final"
    },
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-msbuild3-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.1",
    "Microsoft.Extensions.Logging.Console": "1.0.1",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.1"
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-msbuild3-final",
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-msbuild3-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%" ]
  }
}

任何建議都會非常受歡迎。謝謝。

熱門答案

"tools": {
  "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-msbuild3-final"
}

版本1.0.0-msbuild3-final僅適用於基於MSBuild的新項目(不是project.json )。請使用版本1.0.0-preview3-final



Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因