ASP.NET MVC4– How to use a Database First EF in a MVC controller
Typically when you generate an Entity Framework (.edmx) from database and then try to create a MVC controller with read/write actions based on this Entity Framework, you will get the following error
xxx is not part of the specified Entity class, and the Entity Class could not be modified to add a DbSet<xxx> property to it. (For example, the Entity class might be in a compiled assembly)
Typically when you follow the steps, you will end up with the screen below, which will give you the error above when you click Add
For some strange reason, this DOESN’T work well with Database first EF, but it works properly with Code First EF.
To get it to work, all you need to do is to
1. Compile the project
2. Manually type in the Data context class (or remove the text in brackets)
Now clicking Add will do the neccessary
Thank you for this! After much googling, this worked! Who would’ve thought … manually type in the Data context class!!! C’mon Microsoft, fix this!
this no exists, start vs2012 with admin user and problem no fired
This is great, I have many nerds giving a lot of solutions for this problem but you are just great. Thanks.
This is awesome!! really helpful for me. Thanks for sharing with us. Following links also helped me to complete my task.
http://www.c-sharpcorner.com/uploadfile/raj1979/unit-testing-in-mvc-4-using-entity-framework/
http://www.mindstick.com/Articles/6dfea253-4698-4eb8-ab20-57d2aa61753a/?Fetch%20Data%20from%20Entity%20Framework%20Using%20ASP%20NET%20MVC4