Problem API developed in Visual Studio 2022 NetCore 6 with Docker compatibility: Works in Debug but fails in Release

I developed an API in Visual Studio 2022 for Net Core 6 with Docker compatibility: And it has problems creating a session and connecting to an MSQL 2019 engine if I run it in Release mode. In Debug, everything works perfectly. In this git repository is the code:

In this same git repository you can see a video: APINetCore6DockerVS2020.mp4 (in Spanish) of how the API behaves whether it is executed locally, where it works, creates the session and connects to the database, both in Debug mode and in Release mode. You can also see how it runs correctly when triggered with Docker and works fine in Debug mode. However, when doing it in Release mode, you cannot create the session and therefore connect to the MSQL Server engine.

I hope you can help me.

Thank you so much.