0

Assume that I have some database at my development PC. I then published my Asp.net App to some client. I took database backup and restored at client side.

After that, I have made some changes on schema of my local database. Those changes are added using Code-First migrations (using package-manager Add-Migration). Now I want to execute these migrations on client database. How do I do that?

For now, I receive this error when I run my new app on client side:

The model backing the 'ApplicationDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

FindOutIslamNow
  • 1,169
  • 1
  • 14
  • 33
  • Consider starting migrations from a clean state http://stackoverflow.com/questions/11679385/reset-entity-framework-migrations – Modar Na Mar 13 '17 at 16:13

1 Answers1

1

Use the -script option of update-database (in the package manager console).

Rather than applying changes to you development database it will generate a script in a new editor tab.

Use the -SourceMigration and -TargetMigration option to define the set of migrations to include in the script (the first migration after the source up to and include the target migration will be included).

Richard
  • 106,783
  • 21
  • 203
  • 265