Add
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.2.5" />
</ItemGroup>
=> Make sure the model of the page enherits : ComponentBase
to you component csproj file