简体   繁体   English

如何通过PowerShell或命令行运行Visual Studio 2017程序包管理器命令

[英]How to run Visual Studio 2017 Package Manager commands through PowerShell or command line

How to run Visual Studio 2017 Package Manager commands through PowerShell or the command line? 如何通过PowerShell或命令行运行Visual Studio 2017程序包管理器命令?

I am using Visual studio 2017 for Entity Framework - Database migration, The following command is run on Package Manager console of Visual Studio: 我正在使用Visual Studio 2017 for Entity Framework-数据库迁移,在Visual Studio的Package Manager控制台上运行以下命令:

  1. Enable-Migrations - ContextTypeName Database.TemplateDbContext 启用迁移-ContextTypeName Database.TemplateDbContext
  2. add-migration InitialCreate add-migration InitialCreate
  3. Update-Database - Script -SourceMigration: $InitialDatabase (To generate migration script) Update-Database-脚本-SourceMigration:$ InitialDatabase(用于生成迁移脚本)
  4. Update-Database - Verbose (To update the database) Update-Database-详细(用于更新数据库)

The above script is working fine, but now I'm working on automation of this database migration without using Visual Studio Package Manager. 上面的脚本工作正常,但是现在我正在不使用Visual Studio程序包管理器的情况下自动进行数据库迁移。 Is there any method to call these commands from either the command prompt or from PowerShell scripts? 是否有任何方法可以从命令提示符或PowerShell脚本调用这些命令?

For migration from Command, you could try 要从Command迁移,您可以尝试

For add-migration InitialCreate , you could try 对于add-migration InitialCreate ,您可以尝试

dotnet ef migrations add InitialCreate

For Update-Database , you could try 对于Update-Database ,您可以尝试

dotnet ef database update

Check Migrations 检查迁移

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

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