Fix Arabic Encoding Problem In MySQL and Asp.Net Core

MySQL UTF8 with UTF8_General_Ci Encoding

When I tried to use MySQL Database with one of my Asp.Net Core applications, I found that all data saved in the database as a strange unreadable text .

after investigating this weird problem (specially that the database was correctly encoded as UTF8 with UTF8_General_Ci type when it was created ).

I found that the problem is with my MySQL Connection String in the appsettings.json file which should include the charset=utf8 part also.

as you can see in the code snippet below

 "ConnectionStrings": {
    "Con": "server=Server_Name;database=Database_Name;user=User_Name;password=User_Password;CHARSET=utf8"
  },

This simple fix solve my problem and the data saved in Arabic without any problems in the database!.

Hope you all have a good day…! 🙂

Leave a comment

Your email address will not be published. Required fields are marked *