Thank you. I also wonder whether it's better practice to add an extension function, e.g. ToViewModel() for the User class. This way we can separate the logic for conversion between these better compared to having it all on the controller.
This way it make look like so:
public async Task<IActionResult> Index()
{
var users = await _context.Users
.Include(u => u.Messages)
.ToListAsync();
var vm = users.Select(u => u.ToViewModel());
return View(vm);
}