.net 无法添加迁移

.net 无法添加迁移,.net,entity-framework,entity-framework-6,.net,Entity Framework,Entity Framework 6,我有一个已成功运行的初始迁移,但是,当我尝试添加一个新迁移时,我被告知我不能,因为迁移正在挂起: PM> Update-Database -TargetMigration 201511051706498_InitialCreate -ConfigurationTypeName MyConfiguration -ConnectionString "__My_Connection_String__" cmdlet Update-Database at command pipeline posi

我有一个已成功运行的初始迁移,但是,当我尝试添加一个新迁移时,我被告知我不能,因为迁移正在挂起:

PM> Update-Database -TargetMigration 201511051706498_InitialCreate -ConfigurationTypeName MyConfiguration -ConnectionString "__My_Connection_String__"
cmdlet Update-Database at command pipeline position 1
Supply values for the following parameters:
ConnectionProviderName: System.Data.SqlClient
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201511051706498_InitialCreate].
Applying explicit migration: 201511051706498_InitialCreate.

PM> Add-Migration -ConfigurationTypeName MyConfiguration
cmdlet Add-Migration at command pipeline position 1
Supply values for the following parameters:
Name: InitialCorrectLedgeringColumns
Unable to generate an explicit migration because the following explicit migrations are pending: [201511051706498_InitialCreate]. Apply the pending explicit migrations before attempting to generate a new explicit migration.
我可以在数据库
\u MigrationHistory
表中看到迁移:

SELECT [MigrationId] FROM [localacount].[dbo].[__MigrationHistory]
给出:

MigrationId
----------------------------------
201511051706498_InitialCreate

(1 row(s) affected)

这是怎么回事?为什么我不能添加下一次迁移?

请确保目标数据库正确,并验证连接字符串


updatedatabase
命令中,您已显式覆盖了连接字符串,但尚未为
addmigration
指定一个连接字符串。后者将使用您上下文中的默认连接字符串-可能是另一个数据库。

您确定目标数据库正确吗?在
updatedatabase
命令中,您明确指定了一个连接字符串,但在
addmigration
中,您使用的是上下文?@lc中的默认连接字符串。就这样!事后看来很明显。谢谢,你想把它作为一个答案吗?有时候只需要再看一眼(或者多喝点咖啡)。很高兴这很容易。通常,只需要把问题打出来。我不知道有多少次我开始输入一个问题,然后发现问题,从来没有提交它!