第二次模型首先改变代码

时间:2014-10-02 07:37:51

标签: asp.net-mvc entity-framework ef-code-first

我最初通过映射模型成功生成了配置和Initialcreate类。

现在我更改了模型(通过添加一个属性)并尝试在项目管理器控制台中执行以下命令。

我尝试过的命令:

PM> add-migration

cmdlet Add-Migration at command pipeline position 1
Supply values for the following parameters:
Name: Configuration
Scaffolding migration 'Configuration'.
The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running `Add-Migration Configuration` again.

PM> update-database -verbose

Using StartUp project 'Demo'.
The project 'Demo' failed to build.
PM> 

当我尝试执行add-migration命令时,它生成了一个与Configuration.cs同名的部分类。现在我发现了两个配置文件,但两个类之间的继承是不同的。我该怎么做或我做错了什么?

之后我用不同的名称再次执行命令并且它工作但是当我执行命令Update-database然后收到我在下面提到的错误:

registeration已存在

1 个答案:

答案 0 :(得分:1)

使用

add-migration YourMigrationName -force