Reputation: 28560
I have an initial migration which has run successfully, however, when I try to add a new one I'm told I cant because the migration is pending:
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.
I can see the migration in the database __MigrationHistory
table:
SELECT [MigrationId] FROM [localacount].[dbo].[__MigrationHistory]
Gives:
MigrationId
----------------------------------
201511051706498_InitialCreate
(1 row(s) affected)
What's going on here? Why can't I add the next migration?
Upvotes: 1
Views: 6507
Reputation: 1
If You can't find the solution from anywhere then check module of entity framework in the project by write on NuGet Package Console 'Get-Module' and check their is more than one entity framework in your project. Next Step is to write "EntityFrameworkCore\Add-Migration" on console after that you will seen on console is "cmdlet Add-Migration at command pipeline position 1 Supply values for the following parameters: Name:" give the name of migration out here and press enter Next Step is to write "EntityFrameworkCore\Update-Database" and check the database is the effect seen in it.
Upvotes: 0
Reputation: 116538
Make sure you're targeting the right database and verify your connection string.
In your Update-Database
command you have explicitly overridden the connection string, but haven't specified one for Add-Migration
. The latter would then be using the default connection string from your context - presumably a different database.
Upvotes: 1