'relation "__EFMigrationsHistory" already exists' when running multiple migration sets

'relation "__EFMigrationsHistory" already exists' when running multiple migration sets

Hello,
I am working on upgrading my company's application, based on dotConnect for PostgreSQL, from EF6 to EF Core. The application has multiple modules with migrations for module-specific entities and all migrations are applied to the same database.
Each module has a dedicated DbContext for generating and applying migrations. The runtime project then retrieves all contexts with reflection, gets pending migrations from all of them and applies them using IMigrator.Migrate().
When running this logic against an empty database, the first migration applies correctly but the first migration from another module results in an exception:
  1. Devart.Data.PostgreSql.PgSqlException
      HResult=0x80004005
      Message=relation "__EFMigrationsHistory" already exists
      Source=Devart.Data.PostgreSql
      StackTrace:
       at Devart.Data.PostgreSql.v.a(Boolean A_0, Boolean A_1, Char A_2, Boolean A_3)
       at Devart.Data.PostgreSql.v.a(Boolean A_0, Boolean A_1)
       at Devart.Data.PostgreSql.v.a(Boolean A_0)
       at Devart.Data.PostgreSql.g.a(Boolean A_0)
       at Devart.Data.PostgreSql.g.a(ad A_0)
       at Devart.Data.PostgreSql.g.e(ad A_0)
       at Devart.Data.PostgreSql.ad.u()
       at Devart.Data.PostgreSql.PgSqlDataReader.e(Int32 A_0)
       at Devart.Data.PostgreSql.PgSqlCommand.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords)
       at Devart.Common.DbCommandBase.InternalExecute(CommandBehavior behavior, IDisposable stmt, Int32 startRecord, Int32 maxRecords, Boolean nonQuery)
       at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior, Boolean nonQuery)
       at Devart.Common.DbCommandBase.ExecuteDbDataReader(CommandBehavior behavior)
       at Devart.Common.DbCommandBase.ExecuteNonQuery()
       at Devart.Common.Entity.c0.ExecuteNonQuery()
       at Devart.Data.PostgreSql.Entity.s.ExecuteNonQuery()
       at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
       at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
With the following script in the ErrorSql property:
  1. CREATE TABLE public."__EFMigrationsHistory" (
      "MigrationId" varchar(150) NOT NULL,
      "ProductVersion" varchar(32) NOT NULL,
      PRIMARY KEY ("MigrationId")
    )
However, when I call IMigrator.GenerateScript() the generated script starts with CREATE TABLE IF NOT EXISTS statement instead of a simple CREATE TABLE. If I run the generated scripts against the database directly instead of using migrations, everything works correctly.
This use case worked without any errors when using the EF6 connector (Devart.Data.PostgreSql.EF6, version 8.0.0).

Used versions:
.NET 8
Microsoft.EntityFrameworkCore.* 8.0.7
Devart.Data.PostgreSql.EFCore 8.3.21.8

Is there a way to configure the migrator to use IF NOT EXISTS when applying migrations?

Best regards,
Jan