Reputation: 73
I received an error when trying to use the update-database migration features with EntityFramework. I used this function very often without problems. Here are my 2 problems classes:
public class Produit
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int Upc { get; set; }
public int? BinId { get; set; }
[ForeignKey("BinId")]
public Bin Bin { get; set; }
}
public class Bin
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int NoBin { get; set; }
public virtual ICollection<Produit> Produits { get; set; }
}
Error:
PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201907231929105_Initial].
Applying explicit migration: 201907231929105_Initial.
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.<.ctor>b__22_4(MigrationOperation op)
at MySql.Data.EntityFramework.MySqlMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken)
at System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList`1 operations, String migrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.GenerateStatements(IList`1 operations, String migrationId)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ApplyMigration(DbMigration migration, DbMigration lastMigration)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClasse.<Update>b__d()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.RunCore()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
Input string was not in a correct format.
The enable-migrations worked and add-migration work too.
I use the packages: MySql.Data.EntityFramework (8.0.17.0) MySql.Data (8.0.17.0)
Upvotes: 0
Views: 302
Reputation: 28207
This looks the same as bug 92561 in MySql.Data.EntityFramework, which is caused by running in a non-US-English locale.
As a workaround, you could try switching your computer's locale to U.S. English to run the migration.
Alternatively, try switching to Pomelo.EntityFrameworkCore.MySql, an OSS implementation of EF Core for MySQL; a lot of people have reported that it's less buggy than Oracle's version.
Upvotes: 1