Reputation: 11
I've created two models Student and StudentContext and when i go to create the Controller i get: Unable to retrieve metadata for 'Code_First_Approach_in_Entity_Framework.Models.Student'. Unable to cast object of type 'System.Data.Entity.Core.ObjectContext' to type 'System.Data.Object.ObjectContext'
I've read through some of the replies here but they don't seem to be related enough to this problem.. they seem to be farther than i am getting ...
Any ideas how i go about getting the controller to create correctly? Suggestions?
Upvotes: 1
Views: 954
Reputation: 1
This problem is a typical problem when trying to add a controller and the connection string in the web.config file isn't correct.
Just for the future, I would suggest you to provide some more information about your issue next time, maybe some sample code (non-sensitive code) from your project or so which will result in a much more detailed or correct answer/solution.
Upvotes: 0
Reputation: 11
I was facing same issue and resolve with this solution - downgrade the Entity Framework 6 of the created project to EF5 (Because ASP.NET MVC 4 scaffolding does not support Entity Framework 6 or later
Happy Coding :)
Upvotes: 1