Whenever I try to use scaffolding with EF in MVC 3 (razor) where the datacontext is in another project I run into problems. The scaffolding process completes as expected and creates the controller and view just fine, but when I run the application I get the following error:
‘ViewData’ is not declared. It may be inaccessible due to its protection level.
I’ve tried creating a completely fresh solution with nothing but the bare bones project templates and I still the get the same thing. What am I missing here??
I figured out my problem thanks to this post.
ASP.NET MVC – Why doesn't my view inherits properly from System.Web.Mvc.ViewPage(of T)
Scaffolding was really just a red herring in this case because the actual issue was just having a strongly typed view using an EntityObject. Adding the assembly to the web.config as stated in the answer fixed my problem.