Transferred from: http://fenglongsheng.com/post/6640.html
Today write a mvc4+entity framework+mysql Small example, found that the Chinese write to the database is n a question mark (garbled oh ~);
I followed the code and found that the data submitted by the page was normal, which indicates that there was a problem with EF writing to the database.
In order to further verify, I tried with SQLServer2008, everything is normal, then find the reason on MySQL ~
But MySQL library code is also UTF8, the table is also UTF8, this is what reason?
Baidu has a, read a few articles also did not solve my problem, nothing but to the Web page, database, EF code to change the same, my original is consistent, is the field code? But how do you change the encoding of a field? Also did not find the method, suddenly see the field sort item is empty, could it be the reason? So change to utf8--test--everything normal ~ There is a picture of the truth:
[Go] FIX: Entity Framework + MariaDb (MYSQL) Chinese garbled