How to Fix “SqlException: Incorrect syntax near ‘$’.” in Duende IdentityServer 7

I run into this annoying problem after the upgrade of IdentityServer to .Net 8. The IDP application works fine, but as soon as I tried to log in on a client, I got this error:

SqlException: Incorrect syntax near ‘$’.

In the console I got a slightly more search-friendly error, that lead to the source of the problem. Entity Framework 8 (EF Core 8) needs at least a database compatibility level of 130 (SQL Server 2016) in SQL Server to support its optimised query. If your version is below, you get the error about the $.

To fix this problem, open SQL Server Management Studio, right-click on your database, select Properties from the context menu and go to the Options section to change the Compatibility level:

Set the compatibility level to anything higher than 130.

With this change in place, you should be able to log-in on your client applications without a problem.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.