Entity Framework Core - Cannot Add First Migration

entity-framework-core visual-studio-2015

Question

I am trying to create my first migration of an ASP.Net Core project I am developing in Visual Studio 2015. My Solution only has the one Project. My project.json file resides in the root of my Project folder.

I right-click on the Project and select 'Open command line > default' and enter the following:

dotnet ef migrations add InitialDatabase

The command line returns:

No project was found. Change the current working directory or use the --project option.

I have tried all different versions of EntityFrameworkCore and Tools. My project.json file is as follows:

{
  "dependencies": {
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.1",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.1",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.1",
    "Microsoft.EntityFrameworkCore": "1.0.2",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.2",
    "Microsoft.EntityFrameworkCore.Design": {
      "type": "build",
      "version": "1.0.2" 
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "type": "build",
      "version": "1.0.0-msbuild3-final"
    },
    "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-msbuild3-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.1",
    "Microsoft.Extensions.Logging.Console": "1.0.1",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.1"
    }
  },

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

Any advice would be extremely welcome. Thanks.

1
3
1/31/2017 5:18:35 PM

Popular Answer

"tools": {
  "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-msbuild3-final"
}

Version 1.0.0-msbuild3-final only works with the new, MSBuild-based projects (not project.json). Use version 1.0.0-preview3-final instead.

5
2/1/2017 4:55:31 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