Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem with applying migrations #180

Open
Paul-KMC opened this issue Dec 7, 2021 · 4 comments
Open

The problem with applying migrations #180

Paul-KMC opened this issue Dec 7, 2021 · 4 comments

Comments

@Paul-KMC
Copy link

Paul-KMC commented Dec 7, 2021

After upgrading the npgsql package to version 6.0.0, EF6 migrations to postgresql 12 are not applied.
When downgrading to version 5.0.11, the problem does not occur.
Trace stack when applying migration:
Applying explicit migrations: [202112070713125_pk_Initialization].
Applying explicit migration: 202112070713125_pk_Initialization.
System.FormatException: The input string was not in the correct format.
at System.Version.VersionResult.SetFailure (ParseFailureKind failure, String argument)
at System.Version.TryParseComponent (String component, String componentName, VersionResult & result, Int32 & parsedComponent)
at System.Version.TryParseVersion (String version, VersionResult & result)
at System.Version.Parse (String input)
at System.Version..ctor (String version)
at Npgsql.NpgsqlMigrationSqlGenerator.Generate (IEnumerable1 migrationOperations, String providerManifestToken) at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations (String migrationId, VersionedModel targetModel, IEnumerable1 operations, IEnumerable1 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 (IEnumerable1 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.EnsureDatabaseExists (Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update (String targetMigration)
at System.Data.Entity.Infrastructure.Design.Executor.Update. <> c__DisplayClass0_0. <. ctor> b__0 ()
at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute (Action action)

@juszczukd
Copy link

juszczukd commented Dec 16, 2021

I think i have similar issue. My error is :

System.FormatException: The input string was not in the correct format.

   System.VersionResult.SetFailure(ParseFailureKind failure, String argument) +14130905
   System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent) +131
   System.Version.TryParseVersion(String version, VersionResult& result) +187
   System.Version.Parse(String input) +83
   System.Version..ctor(String version) +31
   Npgsql.NpgsqlMigrationSqlGenerator.Generate(IEnumerable`1 migrationOperations, String providerManifestToken) +224
   System.Data.Entity.Migrations.DbMigrator.GenerateStatements(IList`1 operations, String migrationId) +89
   System.Data.Entity.Migrations.Infrastructure.MigratorBase.GenerateStatements(IList`1 operations, String migrationId) +83
   System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto) +1763
   System.Data.Entity.Migrations.DbMigrator.ApplyMigration(DbMigration migration, DbMigration lastMigration) +1027
   System.Data.Entity.Migrations.Infrastructure.MigratorBase.ApplyMigration(DbMigration migration, DbMigration lastMigration) +80
   System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +297
   System.Data.Entity.Migrations.Infrastructure.MigratorBase.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +88
   System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration) +986
   System.Data.Entity.Migrations.<>c__DisplayClass42_0.<Update>b__0() +49
   System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +771
   System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +72
   System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +178
   System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update() +48
   System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) +270
   System.Data.Entity.Internal.<>c__DisplayClass66_0`1.<CreateInitializationAction>b__0() +230
   System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +154
   System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +730
   System.Data.Entity.Internal.<>c.<InitializeDatabase>b__58_0(InternalContext c) +43
   System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +230
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +340
   System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +180
   System.Data.Entity.Internal.InternalContext.Initialize() +69
   System.Data.Entity.Database.Initialize(Boolean force) +114

I traced the issue to postgres server version. I'm running postgres in docker (i tried newest 12-buster and 13-buster versions).
Postgres version as returned by NpgsqlServices.GetDbProviderManifestToken is 12.8 (Debian 12.8-1.pgdg100+1) and is not parsed properly.

@juszczukd
Copy link

Any update on this ?
This error is a show stopper, and forced me to downgrade Npgsql to version 5.
To show that it's not only postgres on docker problem i have checked version returned by SELECT version(); on postgres 12.9 on windows and it's PostgreSQL 12.9, compiled by Visual C++ build 1914, 64-bit. Postgres on linux returns PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5), 64-bit.

@roji
Copy link
Member

roji commented Jan 27, 2022

@juszczukd the EF 6 (non-Core) provider is pretty much archived at this point - no efforts are going into it.

I'd recommend against trying to use the EF 6 provider with newer versions of Npgsql, since those setups aren't being tested and may have various incompatibilities.

Ledragon pushed a commit to Ledragon/EntityFramework6.Npgsql that referenced this issue Jun 10, 2022
@Ledragon
Copy link

Hi all,
Just submitted a PR to tentatively fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants