Rowan Miller explained how to script Migrations from code, but his code was write using a pre-RTM version of Code First Migrations and doesn´t work when using EntityFramework 4.3.1.

I did some reflector work and get a solution that should work.

The most obvious difference is that some classes was renamed. Another point, at least in my case I needed to configure some additional things, like MigrationsAssemblyand MigrationsNamespace, these properties are used to find Code-Based migrations, that is what I want instead of use Automatic Migrations.