我正在尝试使用EntityFrameworkCore在Visual Studio Code中构建DotNetCore WebApi。
我已经阅读了许多教程,但总是在运行以下命令时遇到问题:
运行Add-Migration InitialCreate
我收到以下错误提示:
无法将“add-migration”识别为cmdlet、函数、脚本文件或可运行的程序名称。
其他教程告诉我应该运行以下命令:dotnet ef migrations add InitialCreate
但我收到以下错误提示:No executable found matching command "dotnet-ef"
这是我的csproj中的引用:
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2"/>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="1.1.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.1.0-preview4-final"/>
我该如何添加迁移?
dotnet-ef
,而是使用dotnet ef
。同时,请确保在包含project.json
的目录中运行dotnet ef
。 - tchelidzedotnet ef
会调用dotnet-ef
,这是非常正常的。 - DavidGMicrosoft.EntityFrameworkCore.Tools.Dotnet
的DotNetCliToolReference
条目? - DavidG