简体   繁体   English

VS Code 中的实体框架迁移

[英]Entity Framework migrations in VS Code

I apply EF Migrations in Visual Studio, but I could not apply them via VS Code.我在 Visual Studio 中应用了 EF 迁移,但无法通过 VS Code 应用它们。

1. What is wrong with the following scripts? 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. Is there any feature like PM Console in VS Code? 2. VS Code 中是否有类似 PM Console 的功能?

3. Can I also apply these scripts via cmd besides VS Code Treminal or CLI? 3.除了 VS Code Treminal 或 CLI 之外,我还可以通过 cmd 应用这些脚本吗?

In VS Code you can either use the CLI or powershell in the terminal window.在 VS Code 中,您可以在终端窗口中使用 CLI 或 powershell。 The syntax for these commands are slightly different.这些命令的语法略有不同。 It looks like you are mixing the powershell syntax and CLI syntax in your samples.看起来您在示例中混合了 powershell 语法和 CLI 语法。 For example for adding a migration the CLI syntax is例如,为了添加迁移,CLI 语法是

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM