How to update a product database by entity framework core 1.0 rc2

.net-core entity-framework-core

Question

In entity framework core 1.0 RC1 when I published a website, it generated a ef.cmd file, I can ran ef database update to update the product database. How can I do it in RC2 when there is no ef.cmd file.

1
0
5/25/2016 2:15:29 AM

Popular Answer

With RC2, you need to install the tooling via your project.json file, then issue dotnet restore. Here is a sample project.json which also brings in EntityFrameworkCore.SQLite:

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

    "dependencies": {
      "Microsoft.NETCore.App": {
        "type": "platform",
        "version": "1.0.0-rc2-3002702"
      },

      "Microsoft.EntityFrameworkCore.Tools": {
        "type": "build",
        "version": "1.0.0-preview1-final"
      },

      "Microsoft.EntityFrameworkCore.SQLite": "1.0.0-rc2-final",
      "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    },

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

    "frameworks": {
      "netcoreapp1.0": {
        "imports": "portable-net451+win8"
      }
    }
}

The important parts here are:

"Microsoft.EntityFrameworkCore.Tools": {
    "type": "build",
    "version": "1.0.0-preview1-final"
}

And

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

These tell the dotnet restore command to download the tooling for entity framework. Now you'll be able to use the .NET Core CLI Entity Framework functionality.

This will let you do things like:

$ dotnet ef migrations add myMigration
$ dotnet ef database update
1
5/31/2016 8:05:08 PM


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