Generate full SQL script from EF 6 First migration steps and multiple configurations

I am trying to create a full SQL script to deploy my application for the first time. I know that this command from the package manager console should create a full SQL script (see this SO question )

Update-Database -Script -SourceMigration:0 

I also read that it $InitialDatabaseshould work instead of "0" for source migration.

However, I have two configurations in my migration folder. I use the following syntax for it:

Update-Database -Script -SourceMigration:0 -ConfigurationTypeName MyConfig

I am returning an empty script for all my configurations.

As a side note, I turned on automatic migrations and did not add any explicit migration to it.

+4
source share
1 answer

Having two migration configurations in the same namespace is an unsupported scenario. We recently closed a bug like this one by design. The workaround is to have migration configurations in separate namespaces.

The most reliable solution to this problem is to simply place your configurations in different folders and use the MigrationsDirectory variable, as shown below, then any explicit migrations created for the configuration should be placed in the same folder

    internal sealed class Configuration : DbMigrationsConfiguration<TestMultipleMigrationsScript.BlogContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
        MigrationsDirectory = @"directory";
    }

}
+1
source

All Articles