Skip to content
Tracon

IMigrationApplier

Namespace Tracon · Assembly Tracon.Abstractions.dll

Applies the pending migrations of the active SQL persistence provider.

public interface IMigrationApplier

Each Use* extension (UsePostgreSql, UseSqlServer, and UseSqlite) registers this interface with Replace, resolving to the provider’s migration runner - the same instance ISqlPersistenceDiagnostics resolves to.

This is the public way to apply migrations from your own code, for example from a deployment step when AutoApplyMigrations is off. The runner itself is not public: each SQL provider package compiles its own copy, and this interface, which lives in Tracon.Abstractions, is the one type all three share. IServiceProvider.GetRequiredService<IMigrationApplier> therefore resolves without knowing which provider is active, even in an application that references more than one of them.

DI lifetime — singleton. Registered as a singleton with Replace by whichever SQL provider is active.

Call this interface; the SQL provider package supplies the implementation, so do not implement or replace it.

Applies every pending migration, in order.

ValueTask<int> ApplyAsync(CancellationToken cancellationToken = default)

cancellationToken CancellationToken

The cancellation token.

ValueTask<int>

The number of migrations applied.