I'm trying to generate a full SQL script to deploy my application for the first time. I know that this command from the package manager console is supposed to create a full SQL script (see this SO question)
Update-Database -Script -SourceMigration:0
I've also read that $InitialDatabase
is supposed to work instead of '0' for the source migration.
However, I have two configurations in my migrations folder. I'm using the following syntax for it:
Update-Database -Script -SourceMigration:0 -ConfigurationTypeName MyConfig
I'm getting back an empty script for all my configurations.
As a note, I have automatic migrations enabled and haven't added any explicit migration to it.
Having two migrations configurations in the same namespace is an unsupported scenario. We closed a bug similar to this as "by design" recently. The workaround is to have your migrations configurations in separate namespaces.
The most reliable solution to this issue would just be to put your configurations in different folders and use the MigrationsDirectory variable as shown below, then any explicit migrations generated for the configuration should be placed in the same folder
internal sealed class Configuration : DbMigrationsConfiguration<TestMultipleMigrationsScript.BlogContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
MigrationsDirectory = @"directory";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With