question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

standard_conforming_strings must be on

See original GitHub issue

I am upgrading an existing .NET Core 3.1 project to .NET 5. After upgrading everything (including Npgsql.EntityFrameworkCore.PostgreSQL to v5.0.0), whenever I try to access PostgreSQL I get the following error: System.NotSupportedException: standard_conforming_strings must be on at Npgsql.NpgsqlConnector.ReadParameterStatus(ReadOnlySpan1 incomingName, ReadOnlySpan1 incomingValue) at Npgsql.NpgsqlConnector.ParseServerMessage(NpgsqlReadBuffer buf, BackendMessageCode code, Int32 len, Boolean isPrependedMessage) at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage) at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext() — End of stack trace from previous location — at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext() — End of stack trace from previous location — at Npgsql.NpgsqlConnection.Open() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.InitializeReader(DbContext _, Boolean result) at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.Enumerator.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)

My application is a .NET 5 Web API and our PostgreSQL database is version 9.6. I am building my context as follows: services.AddDbContext<OfficelinkContext>(opts => opts.UseNpgsql(configuration.GetConnectionString(“OfficelinkConnection”), optionsBuilder => { optionsBuilder.MigrationsAssembly(“OfficelinkRepository”); optionsBuilder.SetPostgresVersion(9, 6); }));

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Drago95commented, Nov 17, 2020

Not using pgbouncer. Connection string trick did the job. Thank you.

0reactions
Drago95commented, Nov 19, 2020

Sorry for the late response. Our database was recently upgraded to PostgreSQL 11.6 and standard_conforming_strings is turned off.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Postgres 9.3 changes the standard_conforming_strings value
Generally, it's a very bad idea to try and keep standard_conforming_strings off. This was changed with Postgres 9.1 for a good reason. It's ......
Read more >
SET STANDARD_CONFORMING_STRINGS
Standard conforming strings must be ON to use Unicode-style string literals ( U&'\nnnn' ). To set conforming strings across all sessions (permanently), use...
Read more >
Setting "Standard_Conforming_strings" parameter to "off" ...
1 Answer 1 ... The impact is that sequences such as \n or \t (there are more) start having a special, non standard...
Read more >
standard_conforming_strings parameter
This controls whether ordinary string literals ( '...' ) treat backslashes literally, as specified in the SQL standard. Beginning in PostgreSQL 9.1, ...
Read more >
Postgrest 8 fails to start if standard_conforming_strings=off
I suspect postgrest assumes standard conforming strings in other places as well now (eg escaping in query parameters was added in v8 I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found