Table of Contents

Namespace Builvero.Infrastructure.Data

Classes

ApplicationDbContext

Entity Framework Core database context for the Builvero application.

DatabaseInitializer

Database initializer that ensures database is created/migrated and default data is seeded. This implementation is idempotent and safe to run on every application startup. Includes retry logic with exponential backoff for handling transient connection failures. Retry configuration can be customized via appsettings.json:

  • Database:MaxRetryAttempts (default: 10 for production, 5 for development)
  • Database:BaseRetryDelaySeconds (default: 2)
  • Database:MaxTotalRetryTimeSeconds (default: 300, i.e., 5 minutes)

Migration Flow:

  • MigrateAsync() is called to apply all pending migrations
  • MigrateAsync() will create the database if it doesn't exist
  • MigrateAsync() will apply all migrations in order, creating all tables and schema
  • After migrations are applied, seeding assumes the schema is fully migrated and all tables exist
  • Seeding operations are idempotent and safe to run multiple times
DbSeeder

Static utility class for seeding initial database data.

UnitOfWork

Implementation of the Unit of Work pattern for managing database transactions and entity tracking.