Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!