"model" 指令需要一个类型名称

The "model" directive expects a type name

安装 .NET Core 3.1 后 none Razor 命令生效。如图所示,所有 Razor 命令都是红色的 enter code here.

@model 
@{
    ViewData["Title"] = "LessonCreate";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}

根据文档,@model 属性需要模型的类型名称。语法是:

@model TypeNameOfModel

如果 Razor 视图不使用模型,您只需向 @model 属性提供模型类型,或者删除该行。

ASP.NET 核心的 Razor 语法参考:

https://docs.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-3.1#directive-attributes