Entity and migration platform - how to update my database on a remote server?

I have included migrations for my framework application. Now I want to update my database on a remote server. I ran this command:

PM> Update-Database -Script 

So he generated a sql script. But this script has all the metadata that I 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 the tables already exist.

How can I generate a sql script that will contain only the necessary updates?

+5
source share
3 answers

. Foo, :

Update-Database -TargetMigration Foo -Script

script Foo. Foo , .

Add-Migration InitialMigration
Add-Migration AddCustomers
Add-Migration AddProjects

, , , InitialMigration. :

Update-Database -SourceMigration InitialMigration -TargetMigration AddProjects -Script

(AddCustomers AddProjects).

+7

, , [projectFolder]/packages/EntityFramework.5.0.0/tools/migrate.exe

:

Migrate.exe [StartupProjectName] /StartupDirectory:"[BIN folder path]" /ConnectionStringName:"[Connection String Name]" /StartupConfigurationFile:"[Path to web or app.config]"
+1

MigrateDatabaseToLatestVersion Initializer, :

Database.SetInitializer(new MigrateDatabaseToLatestVersion<MyDbContext, Configuration>());
+1

All Articles