After upgrading to .net core 3.1(3.1.12 sdk) everything works fine on localhost(hosting model outofprocess and inprocess) but when publishing to azure i have issues with the inprocess hosting model, it does not run at all and i get the error below.
After some further investigation and updating every package(including entity framework) to 3.1.12 compatibility, switching every project from Any CPU to x64, solving any compatibility issues with all packages, the code still breaks, but i found out where, and i still can't determine why this happens.
Also the error comes from this part of code(ADDED TRY CATCH TO SEE IF THE APP WORKS WITHOUT IT, AND IT DOES BUT WE NEED THIS PART, AND I'M PRETTY SURE OTHER STUFF WILL BREAK FURTHERMORE):