How to create unique index case insensitive at entity framework core 2.1

.net-core ef-core-2.1 entity-framework entity-framework-core npgsql

Question

I use npqsql 4+ and efcore 2.1+, how I can create unique invariant case insensetive constraint on field?

The following construction doesn't work:

modelBuilder.Entity<Company>().HasAlternateKey(city => city.Name.ToUpperInvariant());
1
1
7/23/2018 9:19:10 AM

Popular Answer

Unfortunately, there doesn't appear to be a way to create an index with a specific collation using the Npgsql driver. The only PostgreSQL specific configuration that can be done on an index is to set the method using the ForNpgsqlHasMethod extension. You have a couple of options:

  1. Create/modify the index with some SQL, perhaps as part of a migration
  2. Go an request the feature on the official Github project, or even write your own and submit a pull request!
2
7/23/2018 10:03:42 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow