Dotnet Core Microsoft.EntityFrameworkCore.Tools.Dotnet没有安装

时间:2017-08-01 05:53:32

标签: mysql xml asp.net-core entity-framework-core

我有一个Dotnet核心项目,我正在尝试安装Microsoft.EntityFrameworkCore.Tools.Dotnet以使用迁移。我在Mac上,所以我使用的是MySql.Data.EntityFrameworkCore包。当我尝试安装命令行工具时,我收到以下错误,但是如果我手动将软件包添加到它将安装的csproj文件中。但是在尝试运行dotnet ef时出现以下错误。

  

Microsoft.EntityFrameworkCore.Tools.Dotnet的版本无法解析。

我尝试使用.net core 1.0.4和.net core 2.0并获得相同的错误。我还尝试将以下内容添加到我的csproj文件中,该文件没有帮助

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

我有什么遗失的吗?

完整的csproj文件:

<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>

类库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 个答案:

答案 0 :(得分:5)

类库中csproj 从include中的包中删除 Dotnet 一词:

错误的方式:

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

正确的方式:

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

Microsoft.EntityFrameworkCore.Tools.Dotnet仅在DotNetCliToolReference中设置:  

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

答案 1 :(得分:4)

删除<PackageReference>的{​​{1}}。它应该只列为Microsoft.EntityFrameworkCore.Tools.Dotnet

答案 2 :(得分:0)

安装Microsoft.EntityFrameworkCore.Tools.Dotnet软件包的先前版本并进行更新。