首页 > 解决方案 > VS Code 中的实体框架迁移

问题描述

我在 Visual Studio 中应用了 EF 迁移,但我无法通过 VS Code 应用它们。

1.以下脚本有什么问题?

dotnet ef migrations enable-migrations -ContextTypeName Demo.ApplicationDbContext -MigrationsDirectory:Migrations
dotnet ef migrations Add-Migration -configuration Demo.Migrations.Configuration Migration_Initial
dotnet ef migrations Update-Database -configuration Demo.Migrations.Configuration

2. VS Code 中是否有类似 PM Console 的功能?

3.除了 VS Code Treminal 或 CLI 之外,我还可以通过 cmd 应用这些脚本吗?

标签: c#entity-frameworkasp.net-corevisual-studio-codeentity-framework-core

解决方案


在 VS Code 中,您可以在终端窗口中使用 CLI 或 powershell。这些命令的语法略有不同。看起来您在示例中混合了 powershell 语法和 CLI 语法。例如,对于添加迁移,CLI 语法是

dotnet ef migrations add Migration_Initial --configuration Demo.Migrations.Configuration

推荐阅读