I am using entity framework 5 with visual studio 2012.
I do have an existing model. Now I want to add a new table to that existing model. For that I have opened the edxm file and using right click I updated the model successfully.
Now, in "Model Browser" under "EntityTypes" for model, I can see the table name exists. But in Solution Explorer it is not showing the auto-generated .cs file for the table I have added newly under .tt file.
I tried "run custom tool" but it has not generated the class. Also have restarted the Visual Studio but result is the same.
Can anyone help me?
Thanks
Problems
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.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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With