[Solved] asp.NETCORE connect to MySQL error: encoding 1252

The error information is as follows:

System.NotSupportedException:“No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.”

Solution:

Add system.Through.nuget.Text.Encoding and system.Text.Encoding.References to codepages

Then add the following code to the code

System.Text.EncodingProvider ppp = System.Text.CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);

OK solve the problem

Read More: