Differences in string comparison semantics in C#/.NET verses different databases has always been a a usability issue.
We decided some time ago that string comparisons that don't specify any StringComparison value will use the database semantics. This results in the most expected (and fast) queries for code written in the most common way.
One thing we want to avoid is a slow, index-missing query being generated without any explicit opt-in to this.
However, if we know the database collation, then we can potentially translate more queries with acceptable fidelity and perf, while at the same time throwing very specific messages for things we can't translate. See thread here: https://github.com/dotnet/efcore/issues/1222#issuecomment-582662058
This needs to involve migrations and model building as well as queries, so this issue is tracking a more holistic approach to this which covers all aspects.
Related:
Also see high-level collations issue #19866
@ajcvickers this is #19866 :trollface:
Circular references.
Stack overflow.
Here are the docs for PostgreSQL collations. tl;dr a collation can be specified at the database level, at the column level (when creating it), or explicitly in the query on. See also this note for why handling collation as part of the type mapping doesn't seem to make sense (for PostgreSQL).
Following our design discussion, here's what we plan to do for 5.0:
At the moment, we don't plan to translate any string equality/comparison which accept the StringComparison enum (#1222) - see https://github.com/dotnet/efcore/issues/1222#issuecomment-611113142.
@ajcvickers I think we've done everything here that we want to do for 5.0 - the issues that remain are in the backlog and I'm not sure we need this issue to track them.
We may also consider closing #673 as we don't intend to do it (instead the decision was to point at the docs).
Most helpful comment
@ajcvickers this is #19866 :trollface: