错误现象:
$ dotnet ef migrations add InitialCreate
$ 无法解析包“Microsoft.EntityFrameworkCore.Tools.DotNet”的版本。
解决方案:
1. 打开项目文件,扩展名:csproj
修改下面的节点:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.2" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" /> <!-- 增加 -->
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /> <!-- 增加 -->
</ItemGroup>
$ dotnet restore
$ dotnet ef migrations add InitialCreate
Bingo!!!