Quote:
the EF core cannot reference the Web API
You've just answered your own question: the mapping needs to be done in a project which has references to both the entity classes and the DTOs you're mapping to.
Personally, I'd be inclined to move the DTOs to their own project, with no references to anything else; and possibly move the mapping code to its own project as well, with references to the DTOs project and the entities project. That way, you can re-use the DTOs project to create a client for your API, and be sure that the definitions match between the server and client.