0
votes

I have a Dotnet core project in which I am trying to install Microsoft.EntityFrameworkCore.Tools.Dotnet to use migrations. I am on a Mac so I am using the MySql.Data.EntityFrameworkCore package. When I try to install the command line tools I get the following error however if I add the package manually to the csproj file it will install. But I get the following error when trying to run dotnet ef.

Version for package Microsoft.EntityFrameworkCore.Tools.Dotnet could not be resolved.

I tried this both with .net core 1.0.4 and .net core 2.0 and get the same error. I have also tried to add the following to my csproj file which doesn't help

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="2.0.0-preview2-final" />
</ItemGroup>

Is there something I am missing?

full csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <UserSecretsId>aspnet-WebApplication-FCC62E5C-58CB-44F6-835B-E0E34F1DE6D7</UserSecretsId>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0-preview2-final" />
    <PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.8-dmr" />
    <PackageReference Include="MySql.Data.EntityFrameworkCore.Design" Version="8.0.8-dmr" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ClassLibrary.Data\ClassLibrary.Data.csproj" />
  </ItemGroup>
</Project>

class library csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.8-dmr" />
    <PackageReference Include="MySql.Data.EntityFrameworkCore.Design" Version="8.0.8-dmr" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="2.0.0-preview2-final" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="2.0.0-preview2-final" />
  </ItemGroup>
</Project>
3

3 Answers

5
votes

In class library csproj Remove the word Dotnet from the package in the include:

Wrong Way:

<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="2.0.0-preview2-final" />

Right Way:

 <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0-preview2-final" />

Microsoft.EntityFrameworkCore.Tools.Dotnet is only set in DotNetCliToolReference:

 <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.Dotnet" Version="2.0.0-preview2-final" />
4
votes

Remove the <PackageReference> for Microsoft.EntityFrameworkCore.Tools.Dotnet. It should only be listed as a <DotNetCliToolReference>.

0
votes

Install a prior version of the Microsoft.EntityFrameworkCore.Tools.Dotnet package and update it.