EF Core 1.1-preview1 Add-Migration error

.net-core entity-framework-core

Question

I am trying to update my net core project to 1.1-preview as well as EF core to the same version. Restoring the project.json works fine, but once I try to use commands like Add-Migration it fails with this error:

Commands could not invoke on target framework 'netcoreapp1.1'.
Commands on ASP.NET Core and .NET Core projects currently only support .NET Core ('netcoreapp1.0') or .NET Framework (e.g. 'net451') target frameworks.

project.json of small console App to test

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

  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.1.0-preview1-*"
    },
    "Microsoft.EntityFrameworkCore": "1.1.0-preview1-final",
    "Microsoft.EntityFrameworkCore.Design": "1.1.0-preview1-final"
  },

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

  "frameworks": {
    "netcoreapp1.1": {
      "imports": "dnxcore50"
    }
  }
}

I am using Visual Studio 2015. Am I missing something or is EF/.net Core 1.1 not supported by the Visual Studio tools right now?

On EF/.net 1.0 it already does not recognize the Add-Migration or dotnet-ef commands, so to get them to work I have to initialize the EF tools manually as decribed here: https://stackoverflow.com/a/37876143/3506081

I also tried using the Microsoft.EntityFrameworkCore.Tools.DotNet as suggested in the release post but that has same issue that it does not recognize dotnet-ef.

Anyone got similar issues?

1
2
5/23/2017 12:13:50 PM

Accepted Answer

I found out that you can do that using the command line, so not within Visual Studio Package Manager Console (strange not sure why). Keep in mind that the commands are not exactly the same, so for creating a migration for instance this is how you would do it:

dotnet ef migrations add InitialMigration

I'm also using:

"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"

and removed the old tools.

I believe that the tooling has not been updated yet to work with Entity Framework Core 1.1 Preview 1. So, what I did as a work around is to change framework version to netcoreapp1.0, do whatever commands I want to run on database, then revert to latest targeted framework.

2
11/3/2016 2:44:26 PM

Popular Answer

This thread shreads some light over this situation.

The tooling is dependent on a certain MSBuild version so make sure that the tools version have the same version. I've got it running on Mac OSX Sierra

.csproj

    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
      <Version>1.0.0-msbuild1-final</Version>
    </DotNetCliToolReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet">
      <Version>1.0.0-msbuild1-final</Version>
    </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
      <Version>1.0.0-msbuild1-final</Version>
    </PackageReference>

After changing the .csproj make sure to run dotnet clean && dotnet restore. In case it fails try rm -rf obj/

Also



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