Benevia.Core.DataGenerator
0.9.16
See the version list below for details.
dotnet add package Benevia.Core.DataGenerator --version 0.9.16
NuGet\Install-Package Benevia.Core.DataGenerator -Version 0.9.16
<PackageReference Include="Benevia.Core.DataGenerator" Version="0.9.16" />
<PackageVersion Include="Benevia.Core.DataGenerator" Version="0.9.16" />
<PackageReference Include="Benevia.Core.DataGenerator" />
paket add Benevia.Core.DataGenerator --version 0.9.16
#r "nuget: Benevia.Core.DataGenerator, 0.9.16"
#:package Benevia.Core.DataGenerator@0.9.16
#addin nuget:?package=Benevia.Core.DataGenerator&version=0.9.16
#tool nuget:?package=Benevia.Core.DataGenerator&version=0.9.16
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:
builder.Services.AddCoreDataGeneration();
await app.Services.InitializeDataGeneratorAsync(ct);
- For each tenant:
- Initializes responsibility definitions first (loads/syncs permissions) so seed scripts can safely resolve responsibilities by name.
- 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.
- 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.9.16)
- Benevia.Core.Postgres (>= 0.9.16)
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.17-ci.136 | 0 | 5/13/2026 |
| 0.9.17-ci.135 | 29 | 5/13/2026 |
| 0.9.17-ci.134 | 42 | 5/12/2026 |
| 0.9.17-ci.133 | 45 | 5/11/2026 |
| 0.9.17-ci.132 | 91 | 5/11/2026 |
| 0.9.17-ci.131 | 50 | 5/11/2026 |
| 0.9.17-ci.130 | 60 | 5/11/2026 |
| 0.9.17-ci.129 | 48 | 5/10/2026 |
| 0.9.17-ci.128 | 55 | 5/9/2026 |
| 0.9.17-ci.127 | 48 | 5/9/2026 |
| 0.9.17-ci.126 | 78 | 5/8/2026 |
| 0.9.17-ci.125 | 50 | 5/7/2026 |
| 0.9.17-ci.124 | 120 | 5/7/2026 |
| 0.9.17-ci.123 | 77 | 5/6/2026 |
| 0.9.17-ci.122 | 53 | 5/6/2026 |
| 0.9.17-ci.121 | 79 | 5/6/2026 |
| 0.9.17-ci.120 | 52 | 5/5/2026 |
| 0.9.17-ci.119 | 49 | 5/5/2026 |
| 0.9.17-ci.118 | 48 | 5/5/2026 |
| 0.9.16 | 201 | 4/28/2026 |