Class SchemaValidationResult
The outcome of comparing the database schema against the entity model.
public sealed class SchemaValidationResult
- Inheritance
-
SchemaValidationResult
- Inherited Members
Remarks
Produced by ValidateSchemaAsync(CancellationToken). Deliberately a report rather than a thrown exception: whether a schema mismatch should stop a server or merely warn depends on the server, and that call belongs to the caller.
This reports pending migrations only. It does not detect model drift — an entity
changed with no migration generated for it. That check existed here and never worked: EF
builds ModelSnapshot.Model with an empty convention set, so the relational model the
differ needs is never attached and the comparison threw on every single startup. EF Core 5
exposes no supported way to rebuild it (SnapshotModelProcessor is design-time only;
IModelRuntimeInitializer and HasPendingModelChanges both postdate it), so the
check was removed rather than left reporting a failure forever. See issue #162. Drift is
caught by scaffolding a migration and asserting it is empty, which belongs in CI where the
design-time package is available.
Constructors
SchemaValidationResult(string[], string?)
Creates a result.
public SchemaValidationResult(string[] pendingMigrations, string? unavailableReason)
Parameters
Properties
IsUpToDate
True when the check ran and found no pending migrations.
public bool IsUpToDate { get; }
Property Value
Remarks
This is narrower than "the schema matches the entity model", and deliberately so. An entity changed without a migration generated leaves nothing pending and still reports up to date here — see the remarks on the class for why that gap is not closed at runtime.
PendingMigrations
Migrations that exist but have not been applied to this database.
public string[] PendingMigrations { get; }
Property Value
- string[]
UnavailableReason
Why the check could not run at all, or null when it ran. When set, every other property is meaningless — nothing was determined.
public string? UnavailableReason { get; }
Property Value
Methods
DescribeProblem()
Builds an operator-facing description of what is wrong and the command that fixes it, or null when there is nothing to report.
public string? DescribeProblem()
Returns
Remarks
The remedy is included deliberately. The failure this guards against presents as missing player data, and someone reading it for the first time has no reason to connect that to a migration they were never told to run.
Unavailable(string?)
Creates a result for a check that could not be performed.
public static SchemaValidationResult Unavailable(string? reason)
Parameters
reasonstringWhy nothing could be determined.