Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda