petercli
petercli

Reputation: 695

Error : Cannot execute this command because Microsoft.EntityFrameworkCore.Design is not installed

I am trying to follow this tutorial: https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html

When I try to run :
Scaffold-DbContext "Server=myserver1;Database=mydb;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

I get this error :
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.

This is part of my project.json

"tools": {
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",

Any ideas?
Peter

Upvotes: 2

Views: 1658

Answers (2)

Baama
Baama

Reputation: 2642

I had a similar issue I could not run add-migration from package manager console; it produced the same error. In my case lacking "type": "platform" for .netcore.app was the issue. I had to change

"Microsoft.NETCore.App": "1.1.0",
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"

to

"Microsoft.NETCore.App":
{
  "version": "1.1.0",
  "type": "platform"
},
"Microsoft.EntityFrameworkCore.Design": "1.1.0",
"Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final"

Then add to tools section

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

Upvotes: 3

Sampath
Sampath

Reputation: 65938

You need to install latest version 1.1.0.That issue was on the 1.0.0-preview2-final.

You can see the details on GIT : EFCore 1.1.0 Preview Final 1 Scaffold-DbContext Error

Upvotes: 0

Related Questions