I enabled migrations for my entity framework application. Now, i want to update my database on my remote server. I ran this command:
PM> Update-Database -Script
So it generated a sql script. But, this script has all the metadata that I actually have in my database, and not the changes that were made; so, when I try to run this sql script on my remote server, it says that tables already exists.
How can i generate sql script, that will contain only necessary updates?
You can target a specific migration for this. If you have a migration called Foo, for example:
It will generate a migration script for the Foo migration. Replace Foo with whatever migration you need to run on that server.
Let’s say you have the above three migrations in your project, and your local database has all of them applied, but the remote database only has InitialMigration. You can run the following:
This will apply two migrations on the remote server (AddCustomers and AddProjects).