I have my data model in project A, in the namespace ProjectA.Model.MyEntities . In project B (an MVC2 project), I reference project A. But when my pages are requested, they are choking saying that ‘type or namespace ProjectA is not known.
When I compile my project, I get no errors. From my controller, the database context seems to be working fine, as references to MyEntities compile fine. Going to definition on MyEntities navigates me to the Model.Designer.cs file in project A.
It’s like project A is reference during static compile, but not at run time.
This is an MVC2 project, running on .Net4, in Visual Studio 2010, using ASPX engine. It is a legacy project, that is why it is MVC2, but it has been upgraded to .Net4.
What do I have to do to get rid of this error. Have been beating my head on the wall over it all morning.
You could try adding the namespace for ProjectA.Model.MyEntities to the web.config, this will inform the application that the namespace is required for all views.
Alternatively, you can use an imports directive at the top of the individual views – this would be more appropriate if you are only using ProjectA’s entities within a limited number of views:
This should be included after the @Page or @Control directive.