Search code examples
c#asp.netasp.net-mvc

C# & ASP.NET MVC - The type or namespace name 'type/namespace' could not be found


I am new to ASP.NET MVC and I am creating a project. First, I created all my models and data access in one project. However I now moved them into separate projects like this:

enter image description here

I updated all the import and for the models it works fine however when I try and update the imports for the ApplicationDBContext which is stored in the DataAccess project it seems as though it's not there and I get an error that it could not be found.

I tried to add project reference to the DataAccess, but every time I do the tick box gets removed when I reopen the project references.

enter image description here

Does anyone know how to fix this problem? Thanks


Solution

  • There are few things to investigate and actions:

    1. Sometimes Visual Studio does not warns about circular dependencies, so make sure DataAccess project does not have reference to web project

    2. Another option is to restart Visual Studio (and optionally remove .vs folder).

    3. As a last resort I sometimes modify csproj files manually (just copy one of existing references in csproj XML and change project name).