实体框架迁移添加列两次 [英] Entity Framework Migration Adding Column Twice

查看:112
本文介绍了实体框架迁移添加列两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Entity Freamework代码第一次迁移。当尝试运行应用程序时,我会收到错误:规范中发生了多个列ID。我在配置中将AutomaticMigrationsEnabled设置为true,因为当我运行项目时,我希望迁移自动运行。



当我尝试运行它时,这是详细的结果包管理器:



应用基于代码的迁移:201211261626569_AddActiveFlagForProjects。

  ALTER TABLE [Projects] ADD [Active] [bit] NOT NULL DEFAULT 1 

[插入迁移历史记录记录]
应用自动迁移:201211261901371_AutomaticMigration。

  ALTER TABLE [Projects] ADD [Active] [bit] NOT NULL DEFAULT 0 

为什么EF试图改变项目表两次?



我正在使用Entity Framework 5.0和SQL CE 4.0。

解决方案

将-IgnoreChanges标记添加到-Migration



http:// e ntityframework.codeplex.com/workitem/652


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.

解决方案

Adding -IgnoreChanges flag to Add-Migration

http://entityframework.codeplex.com/workitem/652

这篇关于实体框架迁移添加列两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆