Modrich.Persistence 0.1.0

dotnet add package Modrich.Persistence --version 0.1.0
                    
NuGet\Install-Package Modrich.Persistence -Version 0.1.0
                    
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="Modrich.Persistence" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Modrich.Persistence" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Modrich.Persistence" />
                    
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 Modrich.Persistence --version 0.1.0
                    
#r "nuget: Modrich.Persistence, 0.1.0"
                    
#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 Modrich.Persistence@0.1.0
                    
#: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=Modrich.Persistence&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Modrich.Persistence&version=0.1.0
                    
Install as a Cake Tool

Modrich.Persistence

Generic migrate-and-seed pipeline for Modrich modules on .NET 10. Each module owns its DbContext and registers IModuleMigrator + IModuleSeeder; this package runs them in order.

What's in the box

  • ModuleSeederRunner.RunAsync(IServiceProvider)
    1. Creates a DI scope.
    2. Resolves every IModuleMigrator and invokes MigrateAsync in ascending Order.
    3. Resolves every IModuleSeeder and invokes SeedAsync in ascending Order.

That's the whole package. The contracts live in Modrich.Abstractions.

Install

dotnet add package Modrich.Persistence

Usage — module-side

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Modrich.Modules;

public sealed class OrdersMigrator : IModuleMigrator
{
    public int Order => 100;

    public async Task MigrateAsync(IServiceProvider services)
    {
        var db = services.GetRequiredService<OrdersDbContext>();
        await db.Database.MigrateAsync();
    }
}

public sealed class OrdersSeeder : IModuleSeeder
{
    public int Order => 100;

    public async Task SeedAsync(IServiceProvider services)
    {
        var db = services.GetRequiredService<OrdersDbContext>();
        if (await db.OrderStatuses.AnyAsync()) return;
        db.OrderStatuses.AddRange(new("New"), new("Paid"), new("Shipped"));
        await db.SaveChangesAsync();
    }
}

public sealed class OrdersApiModule : IApiModule
{
    public string Name => "Orders";

    public void RegisterApiDependencies(IServiceCollection services, IConfiguration configuration)
    {
        services.AddDbContext<OrdersDbContext>(o =>
            o.UseSqlServer(configuration.GetConnectionString("Default")));

        services.AddScoped<IModuleMigrator, OrdersMigrator>();
        services.AddScoped<IModuleSeeder,  OrdersSeeder>();
    }
}

Usage — host-side

using Modrich.Persistence;

var app = builder.Build();

await ModuleSeederRunner.RunAsync(app.Services);

app.Run();

Modules run in the order they assign — pick conservative numbers (10, 100, 200) so later modules can slot between earlier ones. All migrators complete before any seeder runs, so a seeder in module A can safely read tables created by module B.

  • Modrich.AbstractionsIModuleMigrator, IModuleSeeder.
  • Modrich.Modularity — discovers and registers your module's services so they end up in the DI container the runner enumerates.

Versioning

Strict semver. EnablePackageValidation is on.

License

MIT.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 104 5/23/2026
0.0.1 97 5/23/2026