Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider use of EF collations #1326

Open
josephdecock opened this issue Jun 6, 2023 · 1 comment
Open

Consider use of EF collations #1326

josephdecock opened this issue Jun 6, 2023 · 1 comment
Assignees
Milestone

Comments

@josephdecock
Copy link
Member

Collation issues with EF have caused bugs in the past, and we work around that by performing a second case sensitive check in memory in our C# code.

EF core 5.0 added support for collations, which might improve this situation:

We can declare in our entity mappings that we need case sensitive collation:

modelBuilder.Entity<Customer>().Property(c => c.Name)
    .UseCollation("SQL_Latin1_General_CP1_CI_AS");

And we can specify a collation in a query:

var customers = context.Customers
    .Where(c => EF.Functions.Collate(c.Name, "SQL_Latin1_General_CP1_CS_AS") == "John")
    .ToList();

Open questions:

  • Level of support for these features in various EF providers
  • Can we set collation where we need it without breaking localizations?
@brockallen
Copy link
Member

First thought -- should this be done in the customer's setup of the DB (globally)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants