【问题标题】:Entity Framework migrations in VS CodeVS Code 中的实体框架迁移
【发布时间】:2021-01-15 12:27:03
【问题描述】:

我在 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-framework asp.net-core visual-studio-code entity-framework-core


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2013-04-04
    • 2015-07-03
    • 2015-05-11
    • 1970-01-01
    • 2017-08-09
    • 1970-01-01
    • 2012-10-15
    相关资源
    最近更新 更多