Unable to resolve SQL variable
Anyone have any tips on how to get rid of this error message? Do I need a certain plugin or something else?

Code in text format:
public async Task<IEnumerable<TModelDao>> GetModelsAsync<TModelDao>(string tableName, int page, int size)
{
var offset = (page - 1) * size;
var sql = $"SELECT * FROM {Schema}.[{tableName}] ORDER BY [id] OFFSET @Offset ROWS FETCH NEXT @Size ROWS ONLY";
await using var connection = connectionFactory.CreateSqlConnection();
connection.Open();
var models = await connection.QueryAsync<TModelDao>(sql, new { Offset = offset, Size = size });
return models;
}
Please sign in to leave a comment.
Hello Jone Jeremiassen ,
Thank you for reaching Rider Forum.
I could not reproduce the issue you are facing:
\
Could you please try tweaking the MSBuild version in Settings | Build, Execution, Deployment | Toolset and Build?
Let me know if that helps.
Thank you for the quick reply Anna Morozyuk!
Here is an image of my MSBuild settings:

Please let me know if I should change anything, thanks!
I tried updating it to use the auto detected MSBuild version, but I am still not able to get rid of the red error message:

It compiles and runs just fine, I just want to get rid of what seems like an error message. Unable to choose schema ^ (Nothing to show).
Unable to resolve variable '@Offset'
Unable to resolve variable '@Size'
I did some more digging. I am only to build the solution with the MSBuild version set to the Visual Studio one. When I put on the auto detect (C:\Program Files\dotnet\sdk\8.0.204), the build fails:
The imported project "C:\Program Files\dotnet\sdk\8.0.204\Microsoft\VisualStudio\v17.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\8.0.204\Microsoft\VisualStudio\v17.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" is correct, and that the file exists on disk. C:\Users\jone.jeremiassen\.nuget\packages\microsoft.build.sql\0.1.3-preview\Sdk\Sdk.targets
My Database.sqlproj:

Have you checked your database connection in Rider?
With setting right database schema and correct SQL dialect in Rider, it should not been mark as error.
The error should just been marked in Rider but will not prevent to build the solution, so it should not related to your build toolchain.
This article would be helpful.
We have the same problem in our projects.
It's funny. It works in some SQL and doesn't in other.
Especially variables as parameter of SQL-Insert lead to this:
The variables in the upper part are fine.
The variables in the lower part are red (unable to resolve).
Best,
Wolfram
For the two SQL commands in the code, are they referring to the same database schema? Ensure you have configured all the database connections for the project.
Yes, it's the same database schema. And I think it's all configured correctly. As you can see in the screenshot - only some variables are marked red. The rest is fine.
Could you share more code snnipt of the issue function, so that we can try to reproduce it?