2

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?

Community
  • 1
  • 1
Mats391
  • 1,199
  • 7
  • 12
  • This was fixed in PR [#17](https://github.com/aspnet/EntityFramework.Tools/pull/17), and should be included in the preview4 release. – bricelam Nov 07 '16 at 22:13

2 Answers2

2

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.

m4design
  • 2,112
  • 3
  • 21
  • 28
  • That solved it. Was expecting the tools to be around already just with some cryptic version number like everything else :) – Mats391 Nov 03 '16 at 14:16
  • For now I just keep target framework at 1.0 and so far everything works. Will try using the command line in case I encounter any issues. – Mats391 Nov 04 '16 at 15:05
0

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

joacar
  • 891
  • 11
  • 28