azure-web-app-serviceasp.net-core-5.0ef-core-5.0azure-linux

InvalidCastException after moving ASP.NET Core 5 application from Windows to Linux


After moving my ASP.NET Core 5 application from Azure Windows app service to Linux app service I am getting these errors on almost all of my endpoints:

InvalidCastException (Unable to cast object of type 'System.Int32' to type 'System.String'.
Unable to cast object of type 'System.Guid' to type 'System.String'., etc.)

SqlNullValueException

After moving back to Windows everything works fine again.

Using EF Core 5 and SQL Azure. I want to believe it is not some sort of .NET Core bug and I am simply missing some configuration because migration from Windows to Linux is quite common.


Solution

  • It seems that it happened because app service plan was too weak. After App Service plan scale up everything works perfectly.