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
<PackageReference Include="Benevia.Core.DataGenerator" Version="0.8.7" />
<PackageVersion Include="Benevia.Core.DataGenerator" Version="0.8.7" />
<PackageReference Include="Benevia.Core.DataGenerator" />
paket add Benevia.Core.DataGenerator --version 0.8.7
#r "nuget: Benevia.Core.DataGenerator, 0.8.7"
#:package Benevia.Core.DataGenerator@0.8.7
#addin nuget:?package=Benevia.Core.DataGenerator&version=0.8.7
#tool nuget:?package=Benevia.Core.DataGenerator&version=0.8.7
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 equalsDemoData(case‑insensitive) demo seed runs after blank baselineAdminUsername(optional, defaultadmin)AdminPassword(optional, defaultAdmin@123)
How It Runs
Register the data generator in your Program.cs:
await services.InitializeDataGeneratorAsync(ct);
- For each tenant:
- Acquires a database lock record (
DataGeneratorkey) to avoid concurrent runs across nodes. - Ensures connection string is set on the shared
DbContext. - Executes baseline (
BlankData) then optional demo preset.
- Acquires a database lock record (
- For each preset:
- Discovers assemblies marked with
BusinessLogicAssemblyAttributeplus 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
Featuresrow with the highest discovered version.
- Discovers assemblies marked with
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:
- All applicable methods (attribute + version > stored OR no existing row) execute sequentially inside the feature instance.
- Highest discovered version is written once (
PersistFeatureVersion).
Extending / Adding a Feature
- Create a class implementing
ICreateDatain a project marked withBusinessLogicAssemblyAttribute. - Give it a stable namespace (used as the feature key).
- Add one or more attribute methods (start with Version = 1.0).
- For future schema / data evolution, add new method(s) with higher Version numbers—never change old versions.
- If ordering is required, add
DependedFeaturesAttributereferencing 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 | Versions 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. |
-
net10.0
- Benevia.Core.API (>= 0.8.7)
- Benevia.Core.Postgres (>= 0.8.7)
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 |