Benevia.Core.DataGenerator 0.8.7

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

Benevia.Core.DataGenerator

Maintainers

High‑level, attribute‑driven data generation engine for Benevia Core / ERP. It bootstraps per‑tenant initial data (blank or demo), applies versioned feature seed scripts, and ensures idempotent incremental upgrades.

Configuration (DataGeneratorConfig)

"Tenants": {
  "tenant-a": {
    "ConnectionString": "Host=localhost;Database=tenant_a;Username=...;Password=...",
    "InitialDataOption": "DemoData",          // or BlankData / empty
    "AdminUsername": "admin",                 // optional override
    "AdminPassword": "Admin@123"              // optional override
  }
}

DataGeneratorConfig fields:

  • ConnectionString (required)
  • InitialDataOption (optional, default "") – if equals DemoData (case‑insensitive) demo seed runs after blank baseline
  • AdminUsername (optional, default admin)
  • AdminPassword (optional, default Admin@123)

How It Runs

Register the data generator in your Program.cs:

await services.InitializeDataGeneratorAsync(ct);
  1. For each tenant:
    • Acquires a database lock record (DataGenerator key) to avoid concurrent runs across nodes.
    • Ensures connection string is set on the shared DbContext.
    • Executes baseline (BlankData) then optional demo preset.
  2. For each preset:
    • Discovers assemblies marked with BusinessLogicAssemblyAttribute plus the generator assembly.
    • Locates concrete types implementing ICreateData.
    • Builds dependency layers via DependedFeaturesAttribute.
    • Runs each layer in parallel.
    • Within a feature type, invokes all methods decorated with the target attribute whose version is newer than stored.
    • Updates / inserts a Features row with the highest discovered version.

Attributes

BlankDataAttribute / DemoDataAttribute

Annotate public instance methods of a class implementing ICreateData:

public class ProductSeed : ICreateData
{
    [DataGenerator(DataKind.BlankData, 1)]
    public void SeedProducts(IDataContext dc, EventContext logic) { /* ... */ }

    [DataGenerator(DataKind.DemoData, 1)]
    public void SeedDemoSkus(IDataContext dc, EventContext logic) { /* ... */ }
}

Rules:

  • Method signature: (IDataContext dataContext, EventContext eventContext)
  • Version must increase monotonically per feature namespace.
  • For updates: add a new method with higher Version; previous methods are skipped once version stored >= their version.

DependedFeaturesAttribute

Apply to a feature class to ensure execution order:

[DependedFeatures("ProductSeed", "PricingSeed")] // Names = other feature class names
public class OrderSeed : ICreateData { ... }

Dependency names map to the class names (namespaces are used as persisted feature names—ensure namespace uniqueness).

Feature Version Tracking

Features model columns:

  • Name (uses feature type namespace)
  • Version (double)
  • CreatedAt

On each run for a feature namespace:

  1. All applicable methods (attribute + version > stored OR no existing row) execute sequentially inside the feature instance.
  2. Highest discovered version is written once (PersistFeatureVersion).

Extending / Adding a Feature

  1. Create a class implementing ICreateData in a project marked with BusinessLogicAssemblyAttribute.
  2. Give it a stable namespace (used as the feature key).
  3. Add one or more attribute methods (start with Version = 1.0).
  4. For future schema / data evolution, add new method(s) with higher Version numbers—never change old versions.
  5. If ordering is required, add DependedFeaturesAttribute referencing other feature class names.

Safety Guidelines

  • Keep seed methods idempotent beyond version gating (avoid inserting duplicates if re-run before version bump).
  • Avoid external network calls inside seed methods; keep them deterministic.
  • Validate any sensitive default credentials are overridden outside development.

Minimal Example

public class CoreSeed : ICreateData
{
    [DataGenerator(DataKind.Blank, 1)]
    public void SeedCore(IDataContext dc, EventContext eventContext) { /* baseline */ }

    [DataGenerator(DataKind.DemoData, 1)]
    public void SeedCoreDemo(IDataContext dc, EventContext eventContext) { /* demo */ }
}

Register your assembly with BusinessLogicAssemblyAttribute so discovery picks it up.

Invocation

Ensure startup calls:

await app.Services.InitializeDataGeneratorAsync(ct);

(Place after migrations / database availability.)

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 (1)

Showing the top 1 NuGet packages that depend on Benevia.Core.DataGenerator:

Package Downloads
Benevia.Core.Contacts

Benevia Core Contacts library for managing contact information and relationships.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.7 77 4/2/2026
0.8.7-ci.46 33 4/2/2026
0.8.7-ci.45 32 4/2/2026
0.8.7-ci.44 36 4/1/2026
0.8.7-ci.43 30 3/31/2026
0.8.7-ci.42 36 3/31/2026
0.8.6 173 3/25/2026
0.8.6-ci.40 43 3/25/2026
0.8.5 96 3/25/2026
0.8.5-ci.38 34 3/25/2026
0.8.5-ci.37 38 3/25/2026
0.8.5-ci.36 41 3/24/2026
0.8.4 164 3/23/2026
0.8.4-ci.34 39 3/23/2026
0.8.4-ci.33 38 3/23/2026
0.8.3 100 3/19/2026
0.8.3-ci.31 41 3/19/2026
0.8.3-ci.30 47 3/19/2026
0.8.3-ci.29 39 3/19/2026
0.8.3-ci.28 36 3/19/2026
Loading failed