简体   繁体   English

检查 DBContext 是否有变化并在锅上生成更新脚本而不是使用包管理器控制台

[英]Check if there are changes in DBContext and Generate update script on the pot instead of using Package Manager Console

I would like to check see whether is there any change in DbContext and generate update script right on the pot instead of using Package Manager Console( update-database -script -force -verbose -startupproject myproject ).我想检查 DbContext 中是否有任何变化,并在锅上生成更新脚本,而不是使用包管理器控制台( update-database -script -force -verbose -startupproject myproject )。

Any solution would be appreciate.任何解决方案将不胜感激。

You can archive it with help of DbMigrator and MigratorScriptingDecorator :您可以在DbMigratorMigratorScriptingDecorator的帮助下将其归档:

var configuration = new Configuration();
var migrator = new DbMigrator(configuration);
//if you want to update database to latest migration
migrator.Update();

//if you want to get above update script without applying it to database
var scriptor = new MigratorScriptingDecorator(migrator);
var script = scriptor.ScriptUpdate(sourceMigration: null, targetMigration: null);

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

相关问题 如何在代码中使用EF而不是Nuget软件包管理器控制台迁移Db? - How to migrate Db using EF in code instead of Nuget package manager console? 使用程序包管理器控制台卸载EntityFramework - Uninstall EntityFramework using the Package Manager Console 有什么方法可以检测何时从 Package 管理器控制台调用 DbContext.OnConfiguring()? - Any way to detect when DbContext.OnConfiguring() is being called from Package Manager Console? 在代码优先环境中从包管理器控制台更新数据库 - update the database from package manager console in code first environment 使用Package Manager控制台添加迁移时定义迁移文件夹 - define migration folder when adding migration using Package Manager Console 使用NuGet软件包管理器控制台为C#安装EMGU OpenCV - Using NuGet Package Manager Console to install EMGU OpenCV for C# 在 Visual Studio 中使用 DTE 的包管理器控制台自动化 - Package Manager Console Automation using DTE in Visual Studio 使用 NuGet 包管理器控制台时无法访问源 - Source unreachable when using the NuGet Package Manager Console 从实体框架中的 DbContext 生成数据脚本 - Generate data script from DbContext in entity framework Asp.Net核心程序包管理器控制台。 安装NuGet库而不创建库/脚本文件夹 - Asp.Net Core Package Manager Console. Installing NuGet library not creating a library/script folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM