The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor'

Shortly after posting this I've solved the issue.

I had upgraded my project to .NET Core 2.1 but one of the references (Microsoft.AspNetCore.All) was version 2.0.8.

Upon updating this to 2.1.0, the project now works as expected.


I am following this tutorial to get started in .net Core:

Getting Started with EF Core on ASP.NET Core with a New database

They use .net core 2, so I started my project in core 2. Previously, I installed core 2.1. When I scaffolded a controller according to the tutorial, I got this error. I found from here the below solution which solved my problem:

enter image description here

In my visual studio package manager console, I ran following three commands:

Install-Package Microsoft.AspNetCore.All -Version 2.0.8
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.0.3
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 2.0.1

Then I tried to scaffold a new controller again. This solved the problem. Works fine.