efcore: 5.0 RC1 Problems in migrations
Upgrading from 3.1 to 5.0 RC1. Migrations just not work. It’s working ok in 3.1 and previous versions.
gsql.PostgresException (0x80004005): 42P01: relation «companies» does not exist
at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
at Npgsql.NpgsqlDataReader.NextResult()
at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Exception data:
Severity: ERROR
SqlState: 42P01
MessageText: relation «companies» does not exist
File: d:\pginstaller_12.auto\postgres.windows-x64\src\backend\catalog\namespace.c
Line: 426
Routine: RangeVarGetRelidExtended
42P01: relation «companies» does not exist
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 16 (5 by maintainers)
I confirm is working on latest RC2 5.0.0-rc.2.20474.5. Great job!!! Closing
OK in RC2 that small project is working okay (don’t know what changed), but my big project still fails so I’ll need to start reducing code again to get the minimal code to reproduce the issue… I’ll start doing that.
Hey @roji thank you!! If you try in 3.1 the error is not happening because is not generating the foreign key. I’m gonna try this with RC2 an I’ll tell you later. Thanks!!!
Thanks, this reproduced for me in RC1, but not in the latest RC2 daily builds (nor in 3.1). Can you please try using the latest RC2 as per these instructions, and confirm that everything works fine?
Maybe @AndriySvyryd or @ajcvickers know to dedup this based on the code sample below.
Minimal repro code
Thanks @ajcvickers The problem is that is generating tables with relations before creating the “parent” table. Example, is generating a “users” table with a “companyId” before creating the Companies table. In the migration file, if I manually change the “companies” table creation to the top, it works. I’ll try to reproduce in a clean repo.