'Razor Model Binding is blank

I have the following model:

public class ReadModel
{
     public string Name { get;set; }
}

public class EditViewModel
{
  public ReadModel Data { get;set;}
}

I then populate this in the controller and pass this to the view:

@model EditViewModel
<form asp-action="Edit">
     <div asp-validation-summary="ModelOnly" class="text-danger"></div>
         <div class="form-group">
             <label asp-for="Data.Name" class="control-label"></label>
             <input asp-for="Data.Name" class="form-control" />
              <span asp-validation-for="Data.Name" class="text-danger"></span>
         </div>
     </div>
</form>

However when the page displays there seems to be now errors but the label is blank and the input is also blank.

Can anyone help me hear?

Update

I can use the old method of

@Html.EditorFor(m => m.Data.Name)

and i get a input textbox along with the data in the textbox

Update

<Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
    </PropertyGroup>


Solution 1:[1]

Answer: The issue was that I was inside an area and had not copied over the _ViewImports which has @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephen Cossgrove