Question

How can I specify the collation of a column, a table, or a database by using annotation or Fluent API? I know there are some clean ways for MySql Provider. However, I couldn't find any way for SQL Server other than executing a raw SQL command.

1
9
1/23/2018 6:02:20 AM

Popular Answer

Looks like it will not be done at all:

Here is the closed Issue in aspnet/EntityFrameworkCore: CodeFirst: Set column collation

We discussed and concluded that setting different collations per column isn't a very common requirement and it's probably not something we would make first class in EF. This would be a good candidate for using annotations to define additional metadata and then extending our SQL generators to process those and specify collation.

The only solution seems to be this one: Entity Framework Code First - Change Table Column Collation

... you can create custom database initializer and execute ALTER TABLE command.

1
2/13/2019 12:39:51 PM


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