-
Notifications
You must be signed in to change notification settings - Fork 544
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
How to use Sql server UTF-8 collation with varchar data type #1983
Comments
probably the same issue has been solved in ef core ? dotnet/efcore#25798 |
This issue has been closed because EF6 is no longer being actively developed. We are instead focusing on stability of the codebase, which means we will only make changes to address security issues. See the repo README for more information. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
i have a database with the Latin1_General_100_CI_AS_SC_UTF8 collation and the schema has all text column as varchar.
We would like to suport unicode, and we read that since sql server 2019 and azure db it's possible with -UTF8 collations (default in azure).
If we configure EF6 with nvarchar datatype (the default) we incurr in many conversion at query time, and problem with indexes since the query parameters are passed as N'string_value'.
So we tried to configure the EF with the varchar type,
modelBuilder.Properties<string>().Configure(c => c.HasColumnType("varchar"));
we correctly read the UTF-8 text, but when we write it, we corrupt it.
Then i tried to configure the column as .IsUnicode(true)
modelBuilder.Properties<string>().Configure(c => c.HasColumnType("varchar").IsUnicode(true));
now EF thows exception wile updating the text :
What am i missing ? What is the correct way to handle this scenario ?
Thanks
EF version: 6.1.3
Database Provider: EntityFramework.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered: