As common in EF Code First I've generated an "Initial Create" migration file where is located an outdated model of my db (I'm developing the app so the model is still changing). Now I have a "new model" defined in my code and instead of creating a new migration for that I just want to update the already existing file, because it still is the initial create migration.
I've tried using this without any luck
Update-database -targetmigration $initialcreate
It returns
Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
You can use the Add-Migration command to write the pending model changes to a code-based migration.
I also tried this one, but it's always creating a new .cs file
Add-Migration InitialCreate
I'll appreaciate your help
Run the Add-Migration InitialCreate command in Package Manager Console. This creates a migration to create the existing schema. Comment out all code in the Up method of the newly created migration. This will allow us to 'apply' the migration to the local database without trying to recreate all the tables etc.
Just delete the initial migration files from the 'Migrations' folder and retry.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With