MySQL C# Text Encoding Problems

There are two things that you need to do to support UTF-8 in the ADO.NET Entity frame work (or in general using the MySQL .NET Connector):

  1. Ensure that the collation of your database of table is a UTF-8 collation (i.e. utf8_general_ci or one of its relations)
  2. Add Charset=utf8; to your connection string.

    "Server=localhost;Database=test;Uid=test;Pwd=test;Charset=utf8;"
    

I’m not certain, but the encoding may be case sensitive; I found that CharSet=UTF8; did not work for me.

Leave a Comment