0

I'm trying to run a raw query in the Postgresql database, but when I try, I get the following error:

ERROR: relation "cards" does not exist
LINE 1: SELECT * FROM Cards

My table name is Cards as it is in the string and not cards.

Code:

var cards = _context.Cards;
var query = cards.FromSqlRaw("SELECT * FROM Cards").ToList();
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 2
    I'm not a C# programmer, but some searching leads me to believe you could do: `cards.FromSqlRaw("SELECT * FROM \"Cards\" ")`. In other words `Cards` needs to be double quoted `"Cards"` to preserve the case otherwise as the error pointed out it is down cased to `cards`. – Adrian Klaver May 01 '22 at 18:31
  • @AdrianKlaver This works very well, thaaanks!!! – Jean Silva May 01 '22 at 18:32
  • https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS –  May 01 '22 at 19:10

0 Answers0