Benevia.Core.DataGenerator 0.8.7

There is a newer version of this package available.
See the version list below for details.
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.9.13-ci.70 0 4/18/2026
0.9.13-ci.69 31 4/17/2026
0.9.12 40 4/17/2026
0.9.12-ci.67 35 4/17/2026
0.9.11 50 4/17/2026
0.9.2-ci.65 37 4/17/2026
0.9.2-ci.64 39 4/17/2026
0.9.2-ci.63 32 4/16/2026
0.9.2-ci.62 36 4/15/2026
0.9.1 128 4/14/2026
0.9.1-ci.60 51 4/14/2026
0.9.0 110 4/13/2026
0.8.10-ci.58 57 4/13/2026
0.8.10-ci.57 43 4/10/2026
0.8.10-ci.56 43 4/10/2026
0.8.9 161 4/10/2026
0.8.9-ci.54 40 4/10/2026
0.8.9-ci.53 38 4/10/2026
0.8.7 170 4/2/2026
Loading failed