mej*_*ggs 2 entity-framework-core visual-studio-code asp.net-core
我正在尝试使用EntityFrameworkCore在Visual Studio代码中构建一个DotNetCore WebApi.
我一直在阅读一些教程,但我总是陷入困境:
跑 Add-Migration InitialCreate
我收到以下错误:
术语"添加 - 迁移"不会被识别为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"/>
Run Code Online (Sandbox Code Playgroud)
如何添加迁移?
为了能够使用命令行CLI来管理迁移,您需要将这些工具作为项目的一部分.确保你的项目中有这样的东西:
<ItemGroup>
<DotNetCliToolReference
Include="Microsoft.EntityFrameworkCore.Tools.Dotnet"
Version="1.0.1" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
从命令行接下来,确保您与csproj文件位于同一目录中并运行以下命令:
dotnet ef migrations add InitialCreate
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2542 次 |
| 最近记录: |