Versioning in Entity Framework Code-First

I have used Entity Framework for some projects over the past years, but never taken advantages of the Code-First functionality provided. However, with the stronger presence of Windows Azure and new services in “Microsoft Could”, I see how “Code-First Migrations” will help me versioning and deploying applications and database definitions.

Earlier this week I tried Code-First functionality together with ASP.NET Web API, but it became too complex to get things running, and I decided to take a step back and concentrate on Code-First Migrations.

After some googling and examples found on and MSDN blogs, I found a simple and great “getting started tutorial”. This is a basic tutorial for “Code-First Migrations” and shows most of the available functions, such as

  • Installing latest version of Entity Framework from NuGet Manager
  • Creating a data model in the model classes
  • Creating database from Visual Studio 2012
  • Adding changes through a new migration
  • Switching between different version/migrations
  • Adding custom code in the migration (class model)
  • Rolling back to original version
  • Generating script for full database
  • Make sure program has the latest version of the database

Full source-code.

Next up:

Combining Code-First and ASP.NET Web API

Found a great post by Jon Galloway, explaining how to create POCO/Model classes for the code-First Migration in Entity Framework.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s