Background:
When I was learning photon Server, I looked at the tutorial using the NHibernate framework to connect to the management MySQL database.
I've only used spring boot in Java before, and I feel a bit similar.
After I wrote it, I started trying to connect to the database, and I made a lot of mistakes. I checked my code and tutorial code carefully, and did not find anything wrong, I can only try to grope.
Here are some of the pits I met:
1. You need to close Sslmode in the configuration connection string
2. There is a problem with Chinese garbled characters
After solving the problem, I found that I had successfully connected to the database and was able to manipulate the database. But what happens when I store Chinese data?? The garbled
I checked the database, the tables, the fields, etc. are encoded in UTF8 format
Internet query, and there is no console application under the solution, no matter how to configure the configuration file, are just superfluous
Finally I can manually connect the encoded characters when I connect to MySQL with PHP,
I open the MySQL my.ini file
There is a line, and the following is commented out.
By literal means we can know that this is the way to connect to the database when the encoding, I put the comments out of the reconnection test. Found a successful solution to the problem of Chinese garbled.
Csharp Connection NHibernate Several points to be aware of