Solution 1:

  1. You delete your old .tt files
  2. You open your edmx file in designer mode (so you can see your model)
  3. Right click on a free space
  4. Select Add Code Generation Item
  5. In the dialog select "EF 6.x DbContext Code Generation Item" (something like this)
  6. Save your edmx and all classes will be generated for you, with the new namespaces and so on

Solution 2:

In addition to the answers given here by Rand Random and Dean Oliver, let me mention the following MSDN link, describing general steps for upgrading to EF6. Don't underestimate the manual steps required...

The road map is (see details in the link given above):

  1. Preparation: Install the Entity Framework 6 Tools for Visual Studio 2012/13

  2. Install the EF6 NuGet package

  3. Ensure that assembly references to System.Data.Entity.dll are removed (Note: Installing the EF6 NuGet package should automatically remove any references to System.Data.Entity from your project for you).

  4. Swap any EF Designer (EDMX) models to use EF 6.x code generation.

    Notes:

    • If you're getting the message "The Entity Data Model Designer is unable to display the file you requested" afterwards, then click on the link modify in the displayed text message "The entity Data Model Designer ... You can modify ...", which will display the tables. Select all with Ctrl+A, then press Del, then right-click and select "Update model from database", and finally save using Ctrl+S. This will update the model to the latest version using the default T4-Template "EF 6.x DbContext Generator".

    • If you have used ObjectContext in your project, then you should consider downloading the template "EF 6.x EntityObject Generator". Then right-click in the model designer, choose "Add code generation item", then choose a name you haven't used yet. It will generate the right classes, afterwards you have to remove all old ("*.tt") files and related generated class ("*.cs") files.

  5. Update namespaces for any core EF types being used, i.e.

    • any type in System.Data.* is moved to System.Data.Entity.Core.*
    • System.Data.EntityState => System.Data.Entity.EntityState
    • System.Data.Objects.DataClasses.EdmFunctionAttribute => System.Data.Entity.DbFunctionAttribute.
      Note: This class has been renamed; a class with the old name still exists and works, but it is now marked as obsolete.
    • System.Data.Objects.EntityFunctions => System.Data.Entity.DbFunctions.
      Note: This class has been renamed; a class with the old name still exists and works, but it is now marked as obsolete.
    • Spatial classes (e.g. DbGeography, DbGeometry) have moved from
      System.Data.Spatial => System.Data.Entity.Spatial

N.B.:

  • More information about available EF templates can be found here at MSDN.

  • If you're getting an obsolete attribute warning after upgrading to EF6.x, check out this SO article: How to get rid of obsolete attribute warning?

Solution 3:

As well as the steps Rand Random suggested. Remember to Install Entity Framework 6 Tools for Visual Studio 2012 if you are using VS2012. download here

This will ensure that EF 6.x DbContext Generator template shows when clicking Step 4: Add Code Generation Item