Migrations: Add-Migration ConfigurationTypeName and Name oddity


There is two contexts in the same DLL and I need to create initial migration for both contexts. I'm giving ConfigurationTypeName and Name parameters to Add-Migration cmdlet and it succeeds for the first context. When I'm running the same Add-Migration command with same Name (="Initial" in my case) but different ConfigurationTypeName, it re-scaffolds the migration in the wrong context. It seems that the Name parameter preceeds the ConfigurationTypeName even though it shouldn't.
Closed Oct 21, 2013 at 6:57 PM by RoMiller
EF Team Triage: This is by design - EF assumes that a different namespace is used for migrations that belong to different models. See last comment from Luke for more details.


lukew wrote Oct 18, 2013 at 9:44 PM

I did manage to repro this bug, it only occurs when the two migrations configurations are in the same namespace. The workaround is to have the migration configuration files in separate namespaces like they are when scaffolded by the Enable-Migrations command.

The workaround is to do something like this:
first configuration
namespace Codeplex1740Investigation.Migrations
    internal sealed class Configuration : DbMigrationsConfiguration<Codeplex1740Investigation.EntityContext>
second configuration
namespace Codeplex1740Investigation.MigrationsTwo
    internal sealed class Configuration : DbMigrationsConfiguration<Codeplex1740Investigation.EntityTwoContext>