-
Notifications
You must be signed in to change notification settings - Fork 228
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
Automatic functional index for string fields #293
Comments
Duplicate of #119. First, consider using the PostgreSQL Otherwise, if you sometimes need case sensitivity but not in this case, check out the following issues: #119 and dotnet/efcore#3986. Long story short, you can define any index you want by using raw SQL in your migrations, and adding a fluent API ( |
Thanks roji! Can I use HasAnnotation in entityBuilder.HasIndex(e => e.Name); to define a functional index like lower(name) but only in PostgreSQL? Thanks! |
I'm not sure I understand... As I wrote above, you cannot use |
Hi roji, If I use citext the index will ingnore that field. Thanks!! |
See the EF Docs. The following should work: if (migrationBuilder.ActiveProvider == "Npgsql.EntityFrameworkCore.PostgreSQL")
{
// your code
} |
Thanks!!! |
Last one, if I have entityBuilder.HasIndex(e => e.Name); in my mapping code and the functional index I duplicate the indexes, can I ignore the entityBuilder.HasIndex(e => e.Name); for NPGSQL? |
When you put If I understand you correctly, the healthiest thing is probably to:
|
Thanks! |
Hi!
Since PostgreSQL is case sensitive, consider this index:
entityBuilder.HasIndex(e => e.Name);
Can I force the index allways make a functional index like "lower(name)"?
That way, when I use linq like Customers.Where(e=> e.Nombre.ToLower().StartWith("something")) PostgreSQL allways use the index.
Sorry for my poor english!!
Thanks!
The text was updated successfully, but these errors were encountered: