.net core 1.0.0 with entity framework core sqlite

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

Question

I am trying to create a .net core application that has a connection to a sqlite database.

I have .net core sdk 1.0 installed and have added the following Nuget-packages to my project:

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

I am using the following project.json file:

{
  "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"
    }
  }
}

Then I ran the following command:

dotnet restore

Now I want to check if the ef tool has been successfully installed to create a migration. But when I run:

dotnet ef --help

I get the following result:

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'.

Is it possible to installe release candidate 2 together with the 1.0 version and do I really have to do this to get entity framework runnging with .net core 1.0?

1
1
7/6/2016 10:40:37 AM

Accepted Answer

I found out how to do this. The changes are based on https://docs.efproject.net/en/latest/miscellaneous/rc2-rtm-upgrade.html.

  1. Change the version of the tools to 1.0.0-preview2-final
  2. Remove the import in the frameworks section
  3. Add a dependency to Microsoft.EntityFrameworkCore.Design

Here is the complete 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": {
    }
  }
}

and for completeness this is the global.json:

{
  "sdk": {
    "version": "1.0.0-preview2-003121"
  }
}
0
7/6/2016 10:39:08 AM

Popular Answer

you have to update both to get to RTM. You can't mismatch versions. Check that your Global.json file has the appropriate "sdk":{ "version" : "1.0.0-preview2-003121" } is present.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow