The type or namespace 'UI' does not exist in the namespace UnityEngine. But UI is present. Need help please,The type or namespace name 'UI' does not exist in the namespace UnityEngine. Need help please

I’m using Unity 2019.3.13 and Visual Studio Community Edition. This issue does not cause build or play errors. Just red squiggly lines that are annoying tbh. Not sure what the problem is. I’ve tried re-importing assets and the delete library solution. They don’t work for me.
I’ve installed an older version of Unity - 2019.3.0. Still the same issue.
This is not specific to the UI namespace. Even the Advertisements namespace is not found.
Interestingly, the UnityEngine.UI reference is present in the Solution Explorer.159180-problem.png

159182-problem2.png

Would really appreciate help with this issue. I’ve browsed several forums for answers but nothing has helped. Has been driving me crazy for days

EDIT : Apparently, the issue is with the scripting backend and api compatibility. To fix this, go to EditProject SettingsPlayer. Scroll down till you find Configuration. Here, set the scripting backend to Mono and the api compatibility to .Net Standard 2.0

go to preferences, then external tools. selected all options above and then click Regenerate files. in visual studio a warning will appear that the project was reloaded. click yes. it will reload everything, and no errors should appear anymore.