Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

ApplicationContext: Passing parameters to Migrations

medianick edited this page · 5 revisions
Clone this wiki locally

ApplicationContext is an object passed in by the Migration Runner that is available to migrations to be used as a switch.

To set the ApplicationContext when running migrate.exe

Run migrate.exe ... --context MyArgument. This will set the application context to the string "MyArgument".

To set the ApplicationContext when running migration in code

Set runner.ApplicationContext to an arbitrary C# object, such as a string: runner.ApplicationContext = "MyArgument"; or when creating the RunnerContext:

var migrationContext = new FluentMigrator.Runner.Initialization.RunnerContext(announcer)
{
    ApplicationContext = clientName
};

To use the ApplicationContext

Inside your migration, you can access the context via this.ApplicationContext. So for instance:

if ((string)this.ApplicationContext == "MyArgument")
    this.Delete.Column("BadColumn").FromTable("MyTable");
Something went wrong with that request. Please try again.