Maybe I’m missing something that was introduced in 4.5.6, but we’re not sure what is going on here. We do not have a namespace of ServiceModel in our code however ServiceModel seems to be added in the precompiled SS Razor Views for every view (359+ errors). Upgraded from 4.0.39 to 4.5.7 (Mar 23).
using MyCompany.MyWebsite.ServiceModel
Why is ServiceModel being added to the precompiled views?
Error 1 The type or namespace name ‘ServiceModel’ does not exist in the namespace ‘MyCompany.MyWebsite’ (are you missing an assembly reference?) C:\dev\MySolution\src\MyCompany.MyWebsite\obj\Debug\MyCompany.MyWebsite.Views.Shared._Layout.cshtml.g.cs 22 29 MyCompany.MyWebsite
The Razor namespaces in Web.config is used to control which namespaces should be added in Razor Views, so you should be able to remove namespaces you aren’t using from there.
This is going to make upgrading more difficult as it wasn’t this way before. Probably going to rethink this upgrade now until a later date…
The problem is none of our models are in our website projects which is what is added in the generated razor pages using MyCompany.MyWebsite.ServiceModel;. We have 4 website projects and 1 core project that contains all of our service models that the web projects reference. There is no need to separate the models into each MyWebsite namespace as it would duplicate every model just about.