Entity framework update model from database not generating cs class for newly added table in tt class

Problems

  1. In case you have table name tblEmployee in Database But after the adding 'Entity Data Model' you have Changed Entity tblEmployee to Employee in EDMX file then Save and Build. But Classes for Changed Name are not Generated Automatically in Model1.tt file.
  2. When "Update Model From Database" for adding new table same Problem occurs.
  3. Also not available in MVC When creating view with Model Class/Create Controller With Actions using EntityFramework

This problem is for early version of VS2012.This problem is solved in upgraded version of VS2012.

Solution

we have solution for this with early version of VS2012 & EF 5.0

Follow steps

  1. Right click On Model1.tt and select 'Run Custom Tool' save and Build Now see classes are generated.
  2. Right click On Model1.Context.tt and select 'Run Custom Tool' save and Build Now see property IN Context class is generated like

    public DbSet<Employee> Employees { get; set; } 
    

Save and Build Solution

Model1Context context=new Model1Context();
List<Employee> empList= context.Employees.ToList();

This worked for me. But Keep in mind that still EF 6.0 not able to make Scaffolding when 'creating controller and view using entityframework' in MVC with this viersion of VS2012. You must Use EF 5.0 or update VS2012 with new update.


Resolved it myself.

The problem was in files filename.Context.tt and filename.tt.

The diagram file name for variable const string inputFile specified in both of the files were different than the existing diagram file (.edmx file). Updated it with existing diagram file name and then updated model from database. Working fine now.


In this case what i do is i just delete the exciting model and then click on add and just add your newly added table for there!

If this is the bug with the edmx file located in a folder it is now fixed - download and install VS 2012 Update 1. You can get it from:

http://www.microsoft.com/visualstudio/eng/downloads#d-visual-studio-2012-update