RikMigrations - Starting from an existing database

by Richard Mason 20. December 2007 06:44

RikMigrations includes support for generating an initial migration from an existing database. Currently this only supports SQL Server databases. The feature was included in the initial release, but hadn't had much testing. Since then I've tested it on a database at work and confirmed it's working correctly (at least to some extent). The migration generator attempts to ensure tables are created in the correct order, but this feature was hacked in and needs improving. In doesn't support circular dependencies so don't even try.

The generator only supports generating in C# at the moment, however it uses CodeDom so other support for other languages is simple to add and a quick hack of the code will provide a version for your favourite language. 

To generate a migration from a database use the following command line:

RikMigrations auto -s:(local) -db:Test -f:Migration.cs 

You can also add the "-sf" flag to write each table into a separate class, but make sure you include a "{0}" in the filename to indicate where to place the name of the table.

kick it on DotNetKicks.com
Comments are closed

About Us

RikWare is a software development company based in Brisbane, Australia. Led by director, Richard Mason, RikWare focusses on solving challenging business problems promptly and effectively.

RikWare is also the owner of Aussie Bushwalking, a free, wiki-like collaboration site for bushwalkers and the creator of RikMigrations, a migration framework for .NET.

Aussie Bushwalking

Want to discover some new bushwalking ideas? Share a few of your own? Aussie Bushwalking is like Wikipedia... but for bushwalkers. Head on over. Anybody can see the walks and it's free to sign up and share your own.



RikMigrations is a database migration library for .NET based on the migrations facility provided by Ruby on Rails. It allows simple upgrading and downgrading of databases using .NET code (such as VB or C#) either from the command line or built into your application. Unlike many other migration frameworks, RikMigrations is a stand-alone library which does not rely on a large surrounding framework.