Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.1K
Vistas
The name 'model , html viewdata' does not exist in current context in ASP.NET Core

I'm trying to develop a website using ASP.NET Core .net 5. When I open *.cshtml file I can see that Razor doesn't work - @using, @model and other directives are not recognized and intellisense doesn't work. When I hover over model I'm given the error from title:

The name 'model' does not exist in current context

@model IEnumerable<Bookstore.Models.Author>
   
<p>
    <a asp-action="Create">Create New</a>
</p>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.id)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.id)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
                @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
                @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
            </td>
        </tr>
}
    </tbody>
</table>
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Judging from your error message, I think it might be a problem with your current version of visual studio, something missing or some configuration problems (of course, it does not exist by default).

The following attempts to solve the steps, all default to the case that there is no problem with your project code, to troubleshoot. You can also follow the link in the first step to learn.

Troubleshooting steps:

1. Verify that your vs2019 is normal?

According to the following tutorial, download the complete sample code to see if it can run normally.

Tutorial: Get started with EF Core in an ASP.NET MVC web app

enter image description here

2. Normal operation, then there may be a problem with the configuration of the csproj file in your code.

3. If it fails to run and the same error occurs, then it is recommended

① Upgrade your vs2019 to the latest version.

② Go to the project path and delete the .vs folder. (if you can't find it, please open it to allow hidden files to be displayed)

③ Shut down and restart your computer. (because you have just upgraded vs2019, you can choose to restart to ensure that there is no problem, but it is not a necessary option)

④ Open the project, rebuild the project, and run.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda