[英]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
:您可以在DbMigrator
和MigratorScriptingDecorator
的帮助下将其归档:
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.