.net核心1.0.0與實體框架核心sqlite

.net-core c# entity-framework-core sqlite

我正在嘗試創建一個與sqlite數據庫連接的.net核心應用程序。

我安裝了.net core sdk 1.0並在我的項目中添加了以下Nuget-packages:

  • Microsoft.EntityFrameworkCore.Sqlite
  • Microsoft.EntityFrameworkCore.Sqlite.Design

我使用以下project.json文件:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite.Design": "1.0.0",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": 
       {
      "version": "1.0.0-final",
      "imports": [ 
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  }
}

然後我運行以下命令:

dotnet restore

現在我想檢查是否已成功安裝ef工具來創建遷移。但是當我跑步時:

dotnet ef --help

我得到以下結果:

The specified framework 'Microsoft.NETCore.App', version '1.0.0-rc2-3002702' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\shared\Microsoft.NETCore.App
  - The following versions are installed:
      1.0.0
  - Alternatively, install the framework version '1.0.0-rc2-3002702'.

是否可以將發布候選版本2與1.0版本一起安裝,我是否真的必須這樣做才能使實體框架與.net core 1.0一起運行?

一般承認的答案

我發現瞭如何做到這一點。更改基於https://docs.efproject.net/en/latest/miscellaneous/rc2-rtm-upgrade.html

  1. 將工具的版本更改為1.0.0-preview2-final
  2. 刪除框架部分中的導入
  3. 向Microsoft.EntityFrameworkCore.Design添加依賴項

這是完整的project.json:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite.Design": "1.0.0",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    }
  },

  "tools": {
    "Microsoft.EntityFrameworkCore.Tools": 
       {
      "version": "1.0.0-preview2-final",
      "imports": [ 
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
    }
  }
}

為了完整性,這是global.json:

{
  "sdk": {
    "version": "1.0.0-preview2-003121"
  }
}

熱門答案

你必須更新兩者才能進入RTM。你不能錯配版本。檢查您的Global.json文件是否具有相應的"sdk":{ "version" : "1.0.0-preview2-003121" }存在。



Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow