views:

208

answers:

2

Are there any tutorials for FluentMigrator? Some "Getting Started..." tutorial would be just awesome. All I was able to find was FluentMigrator.Tests (unit tests), inside FluentMigrator source, which are not as helpful as "Getting Started..." would be.

A: 

Since fluent migrator is a fork of Migrator .NET you might find the getting started for Migrator .net helpful

Mike Two
I've read it, but I still don't understand how it works. How to execute the migrations? I have an existing project, and I just want to add few classes to the project and run the migrations from THAT project, with no external tools. Is it possible in Fluent Migrator? Something like `FluentMigrator.Migrate("database path", typeof(Migration024));`, which I would call in `Program.Main()`.
Paja
+1  A: 

I cribbed this from their source code...

using (IAnnouncer announcer = new TextWriterAnnouncer(Console.Out))
{
   IRunnerContext migrationContext = new RunnerContext(announcer) 
   { 
      Connection = "Data Source=test.db;Version=3", 
      Database = "sqlite", 
      Target = "migrations" 
   };

   TaskExecutor executor = new TaskExecutor(migrationContext);
   executor.Execute();
}

I use code similar to this in a custom action class in WiX. Target is the name of the assembly you want to execute. In your case, it would be whatever assembly is produced by your migration project. There are other options on the IRunnerContext you can set. Like Namespace, PreviewOnly, etc. Unfortunately, it isn't documented so you'll have to dig into the code to figure it out. The project that generates the Migrate.exe assembly is where I found most of this.

Justin Rudd