Hi,
Welcome to our community! 
In Unity, go to Edit > Preferences > External Tools. Is your preferred script editor selected? Also check if the “Visual Studio Editor” package is installed in the Package Manager. If you use Rider, look for “Rider Editor” (I think that’s the name of the required package).
If nothing helps, close Unity and VS. Then go to your project folder and delete the *.sln and *.csproj files. Then open Unity again, double click on your script and have Unity open your script editor.
Did this help?
See also:
- Forum User Guides : How to mark a topic as solved