Entity Framework code first migration

Migration is one of the key features of Entity Framework and you strongly need it when you’re developing in “Code-First” style which is my favorite. From time to time however, it may irritate you by throwing exceptions.

Initial configuration

  1. Install Entity Framework
  2. Issue Enable-Migration command in Console Manager
  3. Set “AutomaticMigrationsEnabled” in your configuration file (created by Enable-Migration command) to “True”.
  4. Issue Update-Database command in Console Manager

Troubleshooting Entity Framework Migration

Troubleshooting process is actually straightforward but it may take time till you figure it how. Just follow these steps if you run to any problems:

  • Delete Data in tables which have been changed
  • Delete all the tables (including _MigrationHistory table) if previous step does not solve your problem.
  • Delete the Database if previous step does not solve your problem.

If you have all of your Data in the “Seed” method then just do the last step – Delete the database.

Read 1014 times Last modified on Monday, 17 August 2015 05:54
Rate this item
0
(0 votes)
About Author
Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

Advanced Programming Concepts
News Letter

Subscribe our Email News Letter to get Instant Update at anytime