forked from fluentmigrator/fluentmigrator
-
Notifications
You must be signed in to change notification settings - Fork 0
ApplicationContext: Passing parameters to Migrations
medianick edited this page Oct 18, 2012
·
5 revisions
ApplicationContext is an object passed in by the [Migration Runner](Migration Runners) that is available to migrations to be used as a switch.
Run migrate.exe ... --context MyArgument
. This will set the application context to the string "MyArgument".
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
};
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");
- Getting FluentMigrator
- How to create a Migration
- Fluent Interface
- Migration Runners
- Use inbuilt database functions when setting the default value
- Sql Server Specific Extensions
- Raw Sql Helper for inserting data
- Auto Reversing Migrations
- Resharper File Template
- Transaction Modes for the Migration Runner
- ApplicationContext: Passing parameters to Migrations
- Dealing with Multiple Database Types
- Filter migrations run based on Tags
- Enforce migration version numbering rules
- Create custom metadata for the VersionInfo table