I have this EF Core query on a SQL Server database to get the database collation (code from Copilot):
var collation = dbContext.Database.SqlQuery<string>($"SELECT collation_name FROM sys.databases WHERE name = DB_NAME()").FirstOrDefault();
I get this response:
SqlQuery result : Microsoft.Data.SqlClient.SqlException: 'Nom de colonne non valide : 'Value'.'
Translation (I think):
SqlQuery result : Microsoft.Data.SqlClient.SqlException: 'Invalid column name : 'Value'.'
I'm using
- Microsoft.EntityFrameworkCore (9.0.7)
- Microsoft SQL Server 2019 (RTM-CU32-GDR) (KB5058722) - 15.0.4435.7 (X64)
Why does this happen?