entity framework - Display Pending Automatic Migrations from Code -


background

we work in geographically distributed team. every often, team on other side of world creates build integration server fails due to

unable update database match current model because there pending changes , automatic migration disabled. either write pending model changes code-based migration or enable automatic migration. set dbmigrationsconfiguration.automaticmigrationsenabled true enable automatic migration.

we use code based migrations.

to simplify trouble shooting, i'm looking method display automatic automatic migration have been applied, automatic migrations allowed, code. environment script new migrations not exist on integration server, problem manifests.

attempted solution

i attempted use dbmigrator as outlined here, seems display code based migrations have not yet been applied.

question

is there code-based method display changes applied, automatic migrations enabled?

here solution worked me

public string getautomaticmigrationsscript<t>() t : dbmigrationsconfiguration, new() {     var configuration = new t();     configuration.automaticmigrationdatalossallowed = true;     configuration.automaticmigrationsenabled = true;     var migrator = new dbmigrator(configuration);     var scriptor = new migratorscriptingdecorator(migrator);     var script = scriptor.scriptupdate(sourcemigration: null, targetmigration: null); } 

usage:

console.writeline(getautomaticmigrationsscript<myconfiguration>(); 

the variable script contain sql script run perform automatic migration. code not perform migration, can paste contents of script ssms , run migration there.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -