作者:alian | 来源:互联网 | 2023-02-13 19:52
我已经使用yoman通过Visual Studio代码编辑器生成ASP.Net Core Web API应用程序.作为参考,我在这里遵循了本教程
API工作正常.但是,我正在尝试将实体框架核心迁移与SQL Server一起使用.当我在Visual Studio代码终端中键入以下内容时:
Add-Migration MyDbInitialMigration
我收到以下消息:
'Add-Migration' is not recognized as an internal or external command, operable program or batch file.
我安装了Microsoft.EntityFrameworkCore.Tools: 1.1.0-preview4-final
依赖项.我使用.Net核心项目管理器(Nuget)扩展来完成此操作.
在Visual Studio 2015中,此命令可从Package Manager控制台正常运行.
我假设使用Visual Studio Code的终端是个问题.但有谁知道如何在VS Code编辑器中使用EF Core Migrations?
谢谢你的帮助.
解
运行该dotnet ef migrations add InitialCreate
命令会产生以下错误:
No executable found matching command "dotnet-ef"
要解决这个问题,我需要安装以下依赖项,并将其添加到工具部分:
Microsoft.EntityFrameworkCore.Tools.DotNet
Dronacharya..
32
添加新迁移的正确格式是 dotnet ef migrations add yourMigrationName
并更新数据库是 dotnet ef database update
1> Dronacharya..:
添加新迁移的正确格式是 dotnet ef migrations add yourMigrationName
并更新数据库是 dotnet ef database update
希望你还能看到这个评论......我在使用dotnet CLI以新的方式找到官方文档时遇到了麻烦.在添加迁移不起作用后,我实际上来到了这个StackOverflow页面.心灵分享你在文档中发现了什么?