Bug #101061 Error generating indexes, "Input string was not in a correct format"
Submitted: 6 Oct 2020 7:54 Modified: 8 Oct 2020 11:32
Reporter: Stian Skjerveggen Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.21.0 OS:Windows
Assigned to: CPU Architecture:Any
Tags: entityframework, MySqlMigrationSqlGenerator

[6 Oct 2020 7:54] Stian Skjerveggen
Description:
When generating an index, MySqlMigrationSqlGenerator will check the MySql version, because 8.0 and above does not like having sortorder on hash indexes.

The check is done by converting the version string from providerManifestToken to double. This is wrong if your culture uses commas (,) to represent decimals, instead of periods.

How to repeat:
Change culture to norwegian, add a migration that will add some kind of index, run update-database. The result will be
```
System.FormatException: Input string was not in a correct format.
   at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.Convert.ToDouble(String value)
   at MySql.Data.EntityFramework.MySqlMigrationSqlGenerator.Generate(CreateIndexOperation op)
   at MySql.Data.EntityFramework.MySqlMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken)
```

Suggested fix:
Please replace code for parsing double on line 571 in MySqlMigrationSqlGenerator
```
if (Convert.ToDouble(_providerManifestToken) >= 8.0 && text == "HASH")
```

with the following
```
double.Parse(providerManifestToken, System.Globalization.CultureInfo.InvariantCulture.NumberFormat)
``` 
or something similar that will respect cultureinfo when parsing version.
[8 Oct 2020 11:32] MySQL Verification Team
Hello Stian Skjerveggen,

Thank you for the bug report.
Imho this is duplicate of Bug #94358, please see Bug #94358.

Regards,
Ashwini Patil