Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EntityFramework update or insert Chinese or non-English text

Actually before i did not use framework or linq, just type in sql statement with Sqlcommand class, i type in insert into table values(N'sample') actually i donot know what is N, but it works for Chinese and other Language, otherwise, it will insert some question mark.

But when i use EntityFramework,this kind of framework always insert some question mark, can i ask how to tackle the issue.

N means Unicode? Can you give me one example that EntityFramework use that sort of thing?

like image 590
stackover Avatar asked Sep 28 '12 01:09

stackover


2 Answers

  1. in .edmx Table, select column -> check its properties and set unicode to true
  2. re-generate table if you are working in Code First Apporach
  3. check your database table, it should be nvarchar or ntext datatype

this way EF will save unicode characters.

enter image description here

like image 149
Saboor Awan Avatar answered Sep 22 '22 09:09

Saboor Awan


I had exact same problem for Nepali Language. I had to convert the datatype of sql server column from varchar to nvarchar and then refresh my *.edmx file in entity framework mapping. Then it worked fine.

varchar(255) => nvarchar(255)

varchar(MAX) => nvarchar(MAX)

Right click on that table mapping in edmx file and refresh. Save the changes.

like image 38
merazuu Avatar answered Sep 22 '22 09:09

merazuu