Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

401
Views
NpgsqlException : "Unknown message code: 74" on dotnet ef database update

When I tried to update(build tables from Models) the PostgreSQL database for the first time I caught this exception:

dotnet ef database update

Npgsql.NpgsqlException (0x80004005): Unknown message code: 74 at Npgsql.Util.PGUtil.ValidateBackendMessageCode(BackendMessageCode code) in C:\projects\npgsql\src\Npgsql\Util\PGUtil.cs:line 63 at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<g__ReadMessageLong|0>d.MoveNext() in C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:line 894 --- End of stack trace from previous location where exception was thrown --- at Npgsql.NpgsqlConnector.Authenticate(String username, NpgsqlTimeout timeout, Boolean async) in C:\projects\npgsql\src\Npgsql\NpgsqlConnector.Auth.cs:line 22 at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken) in C:\projects\npgsql\src\Npgsql\NpgsqlConnector.cs:line 393 at Npgsql.NpgsqlConnection.<>c__DisplayClass32_0.<g__OpenLong|0>d.MoveNext() in C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:line 241 --- End of stack trace from previous location where exception was thrown --- at Npgsql.NpgsqlConnection.Open() in C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:line 119 at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlDatabaseCreator.Exists() at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists() at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) Unknown message code: 74

unfortunately, I couldn't find any clue about this exception, and as you see the exception is totally unclear.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

After hours of investigation and reading similar errors and study the source code of the PGUtil.cs, I suspected to the communication problem.

And Bingo. the root of the problem was the wrong port number committed by my colleague.

public class IdentityResourceContextFactory : IDesignTimeDbContextFactory<IdentityResourceContext>
    {
        public IdentityResourceContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder<IdentityResourceContext>();
            optionsBuilder.UseNpgsql("Username=postgres;Password=p@$$word;Host=localhost;Port=3306;Database=Identity;");

            return new IdentityResourceContext(optionsBuilder.Options);
        }
    }

When I changed the port number to the correct one everything goes well:

Username=postgres;Password=p@$$word;Host=localhost;Port=5432;Database=Identity;

I know it might be totally unrelated to the Exception message and because of that I share it here.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!