After upgrading my .net project to .net 9. I had to first update visual studio and for that "Incorrect syntax near '$'." i had to run a query like: ALTER DATABASE MyDb SET COMPATIBILITY_LEVEL = 140 GO (you have to check the apropriate compatibility level for your sqlserver version)