How do I make contains case-insensitive in ef core 2?
You would be better off using LIKE
operator, e.g.
if (!String.IsNullOrEmpty(searchString))
{
customers = customers.Where(x => EF.Functions.Like(x.Email, $"%{searchString}%"));
}
starting from version 2.1 of the EF Core, you can use HasConversion(). But the information in the database will be stored in lowercase:
builder.Property(it => it.Email).HasConversion(v => v.ToLowerInvariant(), v => v);
I solved a similar problem. This change solved all my problems.