Nabs.Launchpad.Core.SeedData 9.0.146

Prefix Reserved
dotnet add package Nabs.Launchpad.Core.SeedData --version 9.0.146
                    
NuGet\Install-Package Nabs.Launchpad.Core.SeedData -Version 9.0.146
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nabs.Launchpad.Core.SeedData" Version="9.0.146" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nabs.Launchpad.Core.SeedData" Version="9.0.146" />
                    
Directory.Packages.props
<PackageReference Include="Nabs.Launchpad.Core.SeedData" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nabs.Launchpad.Core.SeedData --version 9.0.146
                    
#r "nuget: Nabs.Launchpad.Core.SeedData, 9.0.146"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nabs.Launchpad.Core.SeedData@9.0.146
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nabs.Launchpad.Core.SeedData&version=9.0.146
                    
Install as a Cake Addin
#tool nuget:?package=Nabs.Launchpad.Core.SeedData&version=9.0.146
                    
Install as a Cake Tool

Nabs Launchpad Core Seed Data Library

A .NET 9 library providing interfaces and abstractions for database seeding and migration operations in the Nabs Launchpad framework.

Overview

The Nabs.Launchpad.Core.SeedData library defines core interfaces for managing database initialization tasks including:

  • Database schema migrations
  • Test data generation and seeding
  • Development environment data setup

This library provides the contracts that implementations can use to handle database setup operations in a consistent manner across the Launchpad platform.

Features

  • Migration Processing: Interface for handling database schema migrations
  • Seed Data Processing: Interface for populating databases with initial or test data
  • Async Support: All operations support cancellation tokens and async patterns
  • Framework Integration: Designed to work seamlessly with dependency injection and hosted services

Core Interfaces

ISeedDataProcessor

Defines a contract for processing seed data operations:

public interface ISeedDataProcessor
{
    Task ProcessAsync(CancellationToken stoppingToken);
}

Use this interface to implement classes that populate your database with:

  • Initial application data
  • Test data for development environments
  • Sample data for demonstrations

IMigrationProcessor

Defines a contract for handling database migrations:

public interface IMigrationProcessor
{
    Task MigrateAsync(CancellationToken stoppingToken);
}

Use this interface to implement classes that:

  • Apply database schema changes
  • Execute migration scripts
  • Ensure database schema is up-to-date

Dependencies

  • .NET 9: Target framework
  • Bogus: Fake data generation library for creating realistic test data

Usage Examples

Implementing ISeedDataProcessor

public class UserSeedDataProcessor : ISeedDataProcessor
{
    private readonly IUserRepository _userRepository;
    private readonly Faker<User> _userFaker;

    public UserSeedDataProcessor(IUserRepository userRepository)
    {
        _userRepository = userRepository;
        _userFaker = new Faker<User>()
            .RuleFor(u => u.FirstName, f => f.Name.FirstName())
            .RuleFor(u => u.LastName, f => f.Name.LastName())
            .RuleFor(u => u.Email, f => f.Internet.Email());
    }

    public async Task ProcessAsync(CancellationToken stoppingToken)
    {
        if (await _userRepository.AnyAsync(stoppingToken))
            return; // Data already exists

        var users = _userFaker.Generate(100);
        await _userRepository.AddRangeAsync(users, stoppingToken);
    }
}

Implementing IMigrationProcessor

public class DatabaseMigrationProcessor : IMigrationProcessor
{
    private readonly ApplicationDbContext _context;

    public DatabaseMigrationProcessor(ApplicationDbContext context)
    {
        _context = context;
    }

    public async Task MigrateAsync(CancellationToken stoppingToken)
    {
        await _context.Database.MigrateAsync(stoppingToken);
    }
}

Dependency Injection Registration

services.AddScoped<ISeedDataProcessor, UserSeedDataProcessor>();
services.AddScoped<IMigrationProcessor, DatabaseMigrationProcessor>();

Using in Hosted Service

public class DatabaseInitializationService : IHostedService
{
    private readonly IMigrationProcessor _migrationProcessor;
    private readonly ISeedDataProcessor _seedDataProcessor;

    public DatabaseInitializationService(
        IMigrationProcessor migrationProcessor,
        ISeedDataProcessor seedDataProcessor)
    {
        _migrationProcessor = migrationProcessor;
        _seedDataProcessor = seedDataProcessor;
    }

    public async Task StartAsync(CancellationToken cancellationToken)
    {
        await _migrationProcessor.MigrateAsync(cancellationToken);
        await _seedDataProcessor.ProcessAsync(cancellationToken);
    }

    public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}

Integration with Launchpad

This library is part of the larger Nabs Launchpad framework and integrates with:

  • Core.Testing.Silos: Provides test data for Orleans silo testing
  • Core.Persistence: Works with Entity Framework contexts for data operations
  • Core.Context: Integrates with application database contexts

Best Practices

  1. Environment-Specific Data: Only seed data appropriate for the current environment
  2. Idempotent Operations: Ensure seed operations can be run multiple times safely
  3. Performance Considerations: Use bulk operations for large datasets
  4. Error Handling: Implement proper error handling and logging
  5. Cancellation Support: Always respect cancellation tokens for graceful shutdowns

Testing

The library includes comprehensive unit tests in the Launchpad.Core.SeedData.UnitTests project to ensure reliability and correctness of the interfaces and any shared implementations.

Contributing

This library follows the Nabs Launchpad coding standards:

  • Use C# 13 features and latest language constructs
  • Follow nullable reference types conventions
  • Implement proper async/await patterns
  • Include comprehensive unit tests

License

Copyright � Net Advantage Business Solutions

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Nabs.Launchpad.Core.SeedData:

Package Downloads
Nabs.Launchpad.Core.Testing.Silos

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.146 26 8/15/2025
9.0.145 88 8/11/2025
9.0.144 93 8/8/2025
9.0.137 88 7/29/2025
9.0.136 86 7/29/2025
9.0.135 89 7/28/2025
9.0.134 139 7/9/2025
9.0.133 136 7/9/2025
9.0.132 138 7/9/2025
9.0.131 144 7/9/2025
9.0.130 144 7/7/2025