0

I am using Visual Studio 2015. And I am develop app with Entity.Core. But I am getting error while using Add-migration command.

I identified my models.

But getting error using the command "Add-migration TestDb" with Nuget Package Console.

Startup project 'src\WebApplication1' is an ASP.NET Core or .NET Core project for Visual Studio 2015. This version of the Entity Framework Core Package Manager Console Tools doesn't support these types of projects.

How can I solve it. And I don't want to Visual Studio 2017. Please do not recommend that. The same operations I can do on my other computer.

I've update my question with project.json.

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0",
    "Microsoft.EntityFrameworkCore": "1.1.1",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.1"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-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%" ]
  }
}
6
  • Post your project.json. You probably have a too new version of the tools for EF in your project.json. But not wanting to switch to VS2017 will block you sooner or later, all new development of the build pipeline and VS Tools will only happen on VS2017. The tools for VS2015 won't be updated anymore. Also you will unlikely have access to the soon to be released .NET Core 2.0/NETStandard 2.0 if you stay at VS2015 Commented Apr 8, 2017 at 10:55
  • I've update my question with project.json upon your request. Commented Apr 8, 2017 at 17:41
  • You didn't even added the tools. You only have them as dependency, but not registered as tools Commented Apr 8, 2017 at 17:43
  • actually i've added. but i cannot see it. == Cannot execute this command because 'Microsoft.EntityFrameworkCore.Tools' is not installed in project 'src\WebApplication1'. Add 'Microsoft.EntityFrameworkCore.Tools' to the 'tools' section in project.json. See go.microsoft.com/fwlink/?LinkId=798221 for more details. == Commented Apr 8, 2017 at 17:48
  • actually, you're right. I think it is necessary to install an older version. Commented Apr 8, 2017 at 20:28

2 Answers 2

1

Docs for EF Core: https://learn.microsoft.com/en-us/ef/core/

Make sure you read the documentation.

So you are getting that error probably for 2 reasons:

1)In your project.json file make sure you have EntityFrameworkCore.Design/Tools added in you dependencies and EntityFrameworkCore.Tools in your tools.

"dependencies": {
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    }.
"tools": {
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

2) Once you sorted the above issue this will allow you to use the appropriate commands in your cli (PM Console) make sure you are in the project directory:

  • Create Migration: dotnet ef migrations add <name>
  • Update Database: dotnet ef database update
Sign up to request clarification or add additional context in comments.

4 Comments

Please note, there is no EF7, which you can already see with the project.json dependencies you have posted. It's called EF Core and it's not limited to .NET Core just because it has "Core" in it's name, you can also use it against .NET Framework >=4.5
actually correct, but it is cannot solve my problem. I think something else is going wrong.
@caras can you update your question with your current project.json file, and are you getting a different error now?
My one didn't work with this combination, it maybe because my .NetCore is a bit older, for me I used 1.0.1 instead of 1.1.0 and it worked.
1

I've got the same error on PM> Update-Database. If you have the latest version of Microsoft.EntityFrameworkCore.Tools (1.1.1 is the latest stable version when I posted this answer) and you are using VS2015, try to downgrade to

Microsoft.EntityFrameworkCore.Tools 1.1.0-preview4-final

Install from package manager : Install-Package Microsoft.EntityFrameworkCore.Tools -Version 1.1.0-preview4-final -Pre

My package.json looks like this :

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.1.2",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.2",
    "Microsoft.AspNetCore.Mvc": "1.1.3",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.2",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.2",
    "Microsoft.AspNetCore.StaticFiles": "1.1.2",
    "Microsoft.EntityFrameworkCore.Design": "1.1.2",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.2",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
    "Microsoft.Extensions.Logging.Console": "1.1.2",
    "Microsoft.NETCore.App": {
      "version": "1.1.2",
      "type": "platform"
    }
  },

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

Hope it helps anyone.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.