Creating new Commands

One of the benefits of using Dot Net Migrations over using other database migrations strategies is how easy it is to extend Dot Net Migrations. Thanks to the Managed Extensibility Framework, Dot Net Migrations allows you to create additional commands and ways to log the application's information to fit your business needs.

When you create a custom command, a lot of information is available at your fingertips.
  • Access to all configured logs.
  • Access to all command line arguments
  • Access to the data access class which provides a simple way of handling connection strings and database commands.

In order to add custom commands into Dot Net Migrations' command list, you need to do the following:
  1. Create a new class library project and reference the DotNetMigrations.Core.dll
  2. Create a new class that will represent the command's entrypoint and have it inherit from the DotNetMigrations.Core.CommandBase abstract class.
  3. Fill in the ValidateArguments method to provide enforcement on how the arguments should be used.
  4. Place the logic for your command in the RunCommand method. This method is called once the ValidateArguments method has returned true.
  5. Compile to a DLL.
  6. Update PlugInDirectory the db.exe.config file to point to a directory you wish to hold all of your custom parts.
  7. Copy the DLL into the directory specified in step 6.
  8. Your Command is now ready to use.

Once the DLL containing your command is in the Plug In directory, Dot Net Migrations will automatically pick it up the next time it runs.

Example:
Coming Soon

Last edited Jan 27, 2010 at 3:03 AM by JamesEggers, version 2

Comments

No comments yet.