Share via


how to save Chinese characters into SQL Server with Entity Framework, c#?

Question

Monday, February 22, 2016 3:23 PM

Originally I have a database and I generate a Entity Framework in Visual Studio 2013. Now they work very well in Visual Studio 2015/2013.

Now I hope to save a Chinese character string into SQL Server with this Entity Framework, I change string type to nvarchar from varchar in sqlserver database. In Entity Framework, I changed the string property Unicode to true from false.

 But every time my any Chinese string is always changed into "???". What is the reason? How to resolve it?

thank you!

All replies (2)

Tuesday, February 23, 2016 1:25 AM âś…Answered | 2 votes

I fix the issue. 

Originally Entity Framework was generated with string type varchar. When I changed the database string type to nvarchar, the Entity Framework still works with varchar type. After I change the string type to nvarchar, I just regenerate a new Entity Framework. and then the chinese characters can be inputted to SQL server database.

Thank you!


Monday, February 22, 2016 5:22 PM

How did you check the strings? Maybe the used approach gives false results.

If possible, try checking the database contents directly, using SQL Management Studio, for example.