Migrations - Existing Databases

Download this episode

Download Video

Description

This is the companion screencast to our Code First Migrations with an existing database documentation. The Migrations - Under the Hood screencast is a pre-requisite to this screencast.

In this Entity Framework screencast we'll explore using Code First Migrations with an existing database. We'll look at how to enable migrations for an existing database and then use migrations to propagate changes in your Code First model to the database. We'll also cover how to apply those migrations to other databases, such as your production database during deployment. You'll then see these principals in action with a demo in Visual Studio.

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Carlos​Mosquera

      Hi, I'm using VS2013 Prof. Edt. Upd. 1 (v12.0.30110.00) following step find this:

      - First, I update with NugGet Packages EF 5 to 6.1 (in .Net 4.0 and 4.5)... also try without this upgrade.

      - In second EF Model Wizard step always show just two options: Generate from datase and empty model.... not 

      - Model is created with different files than your video (.diagram, .tt with clases files related, .designer.cs, etc.)

      - My Package Manager Console Host use Version 2.8.50126.477 not 2.7.41101.371 like yours.

      - When I try to run Enable-Migrations -ContextTypeName MyModelName show me this:

      Creating a DbModelBuilder or writing the EDMX from a DbContext created using Database First or Model First is not supported. EDMX can only be obtained from a Code First DbContext created without using an existing DbCompiledModel.

      Please help!

    • User profile image
      Carlos​Mosquera

      Find the problem:

      - First should install Entity Framework 6.1.0 Tools for Visual Studio 2012 & 2013

      - Then update to EF6.1

      - Follow video.

      Thanks.

    • User profile image
      dbcontext

      When defining models with Entity Framework's Code First and a DbContext class, I find the "View Model" feature of the Entity Framework Power Tools Beta 3 completely indispensable. Without it, I only *think* I know what I've told EF my model should be but I don't really know how Code First will interpret the information I've provided.

      Any plans to get this feature back ? PLEASE!!

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.