efcore.pg
efcore.pg copied to clipboard
Migrations called twice
NpgsqlMigrator.cs contains method MigrateAsync with following code:
await base.MigrateAsync(targetMigration, cancellationToken).ConfigureAwait(false);
...
var reloadTypes = migrations
.SelectMany(m => m.UpOperations)
.OfType<AlterDatabaseOperation>()
.Any(o => o.GetPostgresExtensions().Any() || o.GetPostgresEnums().Any() || o.GetPostgresRanges().Any());
Access to m.UpOperations forces to call BuildOperations:
public virtual IReadOnlyList<MigrationOperation> UpOperations
=> _upOperations ??= BuildOperations(Up);
So all migrations will call Up() - that would second call for each migration, because MigrateAsync is already called in the beginning. This logic can potentially break some migrations, if they relying on "call once" logic