Hierharchy IDs can be used to vastly improve database performance in certain scenarios.
This repo has a sample implementation of this, using Entity Framework and SQL Server. It relies on database triggers to maintain the Hierarchy ID values and has a stored procedure for updating all the hierarchy IDs. The latter is important when you need to move nodes around in the hierarchy: You then need to update the hierarchy IDs of the node being moved and all nodes below it in the hierarchy.
This example uses a simple string for the Hierarchy ID. SQL Server does have a native Hierarchy ID type, and there is even support for it in Entity Framework. It has some benefits, but I think it is more complex than useful in this particular scenario. I also think it is more aimed at self-referential hierarchies, which this example does not use.
This example uses "old" Entity Framework but it should work almost exactly the same in EF Core.