Migration, Code First Database (EF)

When you are developing your web service, and working with your data set, often you need to make modification to your data set, and definition of your data set.  We can simply initialize (aka, delete and start clean) or migrate to continue on with data you have.

There are two types of migration Automatic Migration and C0de-Based Migration.  I am a lazy guy and I typically choose Automatic Migration, but I do come across situation where I have to run Code-Base migration, so I ll cover both here.

First you have to enable migration. Go to package manager console and run,

Then you should see something like;

Now you should see Migration folder being created, and we check Configuration.cs within that folder.  Then we will edit value for AutomaticMigrationEnabled to true to enable Automatic Migration.

Then we just run command below to let them automatically update whatever and however they want.


Next, I will cover the manual migration process.

You can also refer to ; https://msdn.microsoft.com/en-us/data/jj591621.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.