I need to implement import function in a table with a string column that have a unique index. To access database I’m using EF Core 8. To make sure import will run smoothly I’m removing all duplicates in C# code, but still import is failing.
I have digged around and found a comparer that should match behaviour of SQL server: CollationInfo.GetCollationInfo("Latin1_General_CI_AS").EqualityComparer
from Microsoft.SqlServer.SqlManagementObjects
package. But still when I’m comparing:
CollationInfo.GetCollationInfo("Latin1_General_CI_AS").EqualityComparer.Equals("ß","SS")
I’m getting false
while trying to import this strings into database will fail because of Unique constraint.
Database is created via EF code first. I’m calling modelBuilder.UseCollation("Latin1_General_CI_AS");
to make sure same collation is used, and when I check the unique index it has this collation set (as well as DB default collation).
Is there any EqualityComparer that matches SQL collation exactly?