I refactored my MVC/Entity Framework projects by separating namespaces into separate projects. So I now have this structure:
MySolution.Data
MySolution.Data.Contracts
MySolution.Model
MySolution.Website
Everything builds and runs in my development environment. However I hit problems when I tried to deploy to my "Staging" server.
The problem I have is that it would not build when I changed the solution configuration to "Staging". In the configuration manager all the projects also have "Staging" configurations. I assume these were created when the new projects were added.
The first thing I tried was to create a new solution configuration with everything copied from Debug named "Solution 2". No luck, still fails.
Then I figured that I only need a different configuration for the Website project - where I transform the configuration file. So I changed the solution configuration, telling it to build and deploy the "Debug" configuration of Hub.Model - which from the first error message looked like the problem project. Sure enough it now builds.
The first error message (of 263) is:
The type or namespace name 'Schema' does not exist in the namespace 'System.ComponentModel.DataAnnotations' (are you missing an assembly reference?) MySolution.Model
So it looks like a problem with references to Entity Framework dlls
While I do have a workaround for now, I am concerned that this unexplained error will come back and bite me at some point in the future - probably just when I am about to deploy an urgent fix.
So why would one of my projects fail to build when I change project configuration?