无法解析Microsoft.EntityFrameworkCore.Tools

时间:2017-02-20 02:31:49

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

我的ASP.NET核心项目大约有一年的历史,并使用EF Core和Postgres。我运行了dotnet migrate,将旧的project.json转换为新的csproj。现在该项目不再编译。具体来说,当我运行dotnet restore时,我收到以下错误:

Unable to resolve 'Microsoft.EntityFrameworkCore.Tools (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.

以下是csproj目前的情况:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.0" />
    <PackageReference Include="Npgsql" Version="3.2.1" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="1.1.0" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4-final" />
  </ItemGroup>

</Project>

如何解决此依赖性问题并重新回到正轨? (理想情况下,我希望尽可能地面向未来)

1 个答案:

答案 0 :(得分:2)

我认为您应该将Microsoft.EntityFrameworkCore.Tools升级到1.1.0-preview4-final版本:

  • 在程序包管理器控制台中运行以下命令

    安装包Microsoft.EntityFrameworkCore.Tools -Version 1.1.0-preview4-final

  • 或手动更改为.csproj文件中的<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0-preview4-final" />

希望这有帮助!