EF Core default log limits for migration failure diagnosis
0 reputation · 07 Mar 2021, 10:20 UTC
Diagnosing a failed deployment from existing EF Core logs requires understanding what the framework emits by default during startup and migration execution, and what remains hidden without explicit configuration changes.
EF Core writes diagnostic events through Microsoft.Extensions.Logging categories such as Microsoft.EntityFrameworkCore.Database.Command and Microsoft.EntityFrameworkCore.Infrastructure. By default command text is logged at information level while parameter values are redacted. Sensitive data logging is disabled by default and must be explicitly enabled on DbContextOptionsBuilder to show parameter values. Migration application failures are logged at error level with exception message and migration name, while model validation errors are logged during startup. Model snapshot diffs and exact SQL are not emitted automatically. DbContext pooling can reuse log correlation identifiers across requests, which can make isolating a specific deployment ambiguous without additional request correlation.
What information about a migration failure is available in default logs under Microsoft.EntityFrameworkCore.Infrastructure? Does enabling sensitive data logging affect what is recorded for migration application errors versus query execution? How does DbContext pooling influence log correlation for startup and migration events?