Bug #94358 MySqlMigrationCodeGenerator thows "Input string was not in a correct format"
Submitted: 15 Feb 2019 23:47 Modified: 23 Jul 2020 19:33
Reporter: Spartak Timchev Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:8.0.15.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: entityframework

[15 Feb 2019 23:47] Spartak Timchev
Description:
When code first migrations is used and system decimal separator is not "."(dot), but instead ","(comma) "Input string was not in a correct formnat" exception is thrown.

MySqlMigrationCodeGenerator uses "Convert.ToDouble" to convert "providermanifesttoken" and check the version, without invariantculture format provider.

How to repeat:
1. Set system decimal separator to ","(comma)
2. Start any project with code first migrations enabled and missing database
3. Try to use database using entity framework. Entioty framework will try to create the database using MySqlMigrationSqlGenerator class and will throw the above exception

Suggested fix:
In MySqlMigrationGenerator.cs file, on line 769 there is:

if (Convert.ToDouble(_providerManifestToken) >= 8.0 && indexType == "HASH")

It should changed to:

if (Convert.ToDouble(_providerManifestToken, System.Globalization.CultureInfo.InvariantCulture) >= 8.0 && indexType == "HASH")
[15 Feb 2019 23:49] Spartak Timchev
Repaired MySqlMigrationSqlGenerator.cs file

Attachment: MySqlMigrationSqlGenerator.cs (text/plain), 46.08 KiB.

[23 Jul 2020 19:33] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.0.22 release, and here's the proposed changelog entry from the documentation team:

An application using Entity Framework code-first migration without the
default system decimal separator, the period character (.), could not
generate a new database. Now, setting the system decimal separator to a
different character is permitted.

Thank you for the bug report.
[8 Oct 2020 11:34] MySQL Verification Team
Bug #101061 marked as duplicate of this one.