问题
I'm running Entity Freamework Code First Migrations. When trying to run the application I get the error: A column ID occurred more than once in the specification. I have AutomaticMigrationsEnabled set to true in the configuration because when I run the project, I want the migrations to run automatically.
This is the verbose results when I tried running it through the package manager:
Applying code-based migration: 201211261626569_AddActiveFlagForProjects.
ALTER TABLE [Projects] ADD [Active] [bit] NOT NULL DEFAULT 1
[Inserting migration history record] Applying automatic migration: 201211261901371_AutomaticMigration.
ALTER TABLE [Projects] ADD [Active] [bit] NOT NULL DEFAULT 0
Why is EF trying to alter the projects table twice?
I'm using Entity Framework 5.0 and SQL CE 4.0.
回答1:
Adding -IgnoreChanges flag to Add-Migration
http://entityframework.codeplex.com/workitem/652
来源:https://stackoverflow.com/questions/13571576/entity-framework-migration-adding-column-twice