剃刀 ASP.NET 核心 HTML 标记帮助程序错误



我在使用剃须刀代码时出错,这是弹出的错误:

'IEnumerable<Employee>' does not contain a definition for 'FullName' and no extension method 'FullName' accepting a first argument of type 'IEnumerable<Employee>' could be found (are you missing a using directive or an assembly reference?)

作为进一步检查,此错误仅发生在

<label asp-for="FullName" class="col-md-2 control-label"></label>
  <div class="col-md-10">
    <input asp-for="FullName" class="form-control"/>
    <span asp-validation-for="FullName" class="text-danger"></span>
</div>

所有其他剃须刀文件都可以...问题与ASP-for有关,我不知道为什么。

我也通过我的类库调用我的模型,它是这样的:

@model IEnumerable<Demo101.DAL.Entities.Models.Employee>

有人可以帮助我吗?

谢谢!

我找到了解决方案。

我只是删除IEnumerable<>,它现在可以完美运行!感谢您@Tacud和@sleeyuen的帮助。

最新更新