Lyo.Seed
3.0.0
dotnet add package Lyo.Seed --version 3.0.0
NuGet\Install-Package Lyo.Seed -Version 3.0.0
<PackageReference Include="Lyo.Seed" Version="3.0.0" />
<PackageVersion Include="Lyo.Seed" Version="3.0.0" />
<PackageReference Include="Lyo.Seed" />
paket add Lyo.Seed --version 3.0.0
#r "nuget: Lyo.Seed, 3.0.0"
#:package Lyo.Seed@3.0.0
#addin nuget:?package=Lyo.Seed&version=3.0.0
#tool nuget:?package=Lyo.Seed&version=3.0.0
Lyo.Seed
A named SeedContributor is run against an ISeedTransport by Lyo.Seed. The graph only wants items (Func<int, T> / ForEach factories). Bogus and other fakers remain in the
host. This package ships two transports: EfSeedTransport<TContext> (AddRange + SaveChangesAsync) and ApiSeedTransport (chunked POST {route}/Bulk, skip via
POST {route}/QueryConcrete).
Features
- No generator dependency. Factories that return
Tgo toSeedGraph.EntityandForEach. Contributors can use Bogus, hand-built objects, or anything else. - EF transport. Each batch is persisted by
EfSeedTransport<TContext>withSaveChangesAsync.Aftercallbacks may callSeedSession.PersistAsyncor useContextfor schema-specific deletes. - API transport.
ApiSeedTransportmaps request types onto Lyo.Api routes, chunks atMaxBulkAmount(default 2000), and fails the run whenCreateBulkResult.FailedCount > 0. - Conflict modes.
Append(default), optionalSkipIfNotEmpty, andReplace(OnClearis required). - EF source.
IEfSeedSourcenames the Postgres schema and opens theDbContext. Hosts that see the interface buildEfSeedTransport<T>without a per-contributor switch.
Examples
Contributor on EF
using Lyo.Common.Core.Identifiers;
public sealed class ParentContributor : SeedContributor
{
public override string Name => "parents";
public override SeedTransportKind SupportedTransports => SeedTransportKind.Ef;
protected override void Configure(SeedGraph graph, SeedOptions options)
=> graph.Entity(options.Count, i => new ParentRow { Id = LyoGuid.CreateV7(), Name = $"p-{i}" })
.ForEach(_ => 2, (parent, i) => new ChildRow { Id = LyoGuid.CreateV7(), ParentId = parent.Id, Label = $"{parent.Name}-{i}" });
}
await using var db = new MyDbContext(options);
var result = await new SeedRunner().SeedAsync(new ParentContributor(), new EfSeedTransport<MyDbContext>(db));
Transport over the API
var catalog = new SeedApiCatalog();
catalog.Map<PersonReq, PersonRes>("Person");
var transport = new ApiSeedTransport(apiClient, catalog);
await runner.SeedAsync(peopleApiContributor, transport, new() { Count = 50 });
Container registration
services.AddLyoSeed();
services.AddSeedContributor<ParentContributor>();
services.AddEfSeedTransport<MyDbContext>();
services.AddApiSeedTransport(api => api.Map<PersonReq, PersonRes>("Person"));
How transports are built
Build EfSeedTransport<TContext> on a live DbContext, or ApiSeedTransport on IApiClient plus a SeedApiCatalog. A contributor that implements IEfSeedSource opens its own
context from the connection string (CreateContext) so the host does not switch on contributor type. ISeedRunner rejects a transport whose Kind is missing from
SeedContributor.SupportedTransports.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Api.Client(direct, lyo)Lyo.Api.Models(direct, lyo)Lyo.Exceptions(direct, lyo)Lyo.Http.Client(direct, lyo)Lyo.Query.Models(direct, lyo)Microsoft.EntityFrameworkCore10.0.5(direct, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5(direct, microsoft)Npgsql10.0.3(direct, third-party)Lyo.Common.Core(transitive, lyo)Lyo.Common.Metadata(transitive, lyo)Lyo.DateAndTime(transitive, lyo)Lyo.Diagnostic(transitive, lyo)Lyo.Hashing(transitive, lyo)Lyo.Json(transitive, lyo)Lyo.Metrics(transitive, lyo)Lyo.PackageMetadata(transitive, lyo)Lyo.Parameters(transitive, lyo)Lyo.Result(transitive, lyo)AngleSharp1.5.0(transitive, third-party)Microsoft.Bcl.AsyncInterfaces10.0.5(transitive, microsoft, netstandard2.0)Microsoft.Extensions.Configuration.Binder10.0.5(transitive, microsoft)Microsoft.Extensions.Http10.0.5(transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5(transitive, microsoft)System.IO.Hashing10.0.5(transitive, microsoft, net10.0)System.Memory4.6.3(transitive, microsoft, netstandard2.0)System.Text.Encoding.CodePages10.0.5(transitive, microsoft)System.Text.Json10.0.5(transitive, microsoft, netstandard2.0)System.Threading.RateLimiting10.0.5(transitive, microsoft)System.Threading.Tasks.Extensions4.6.3(transitive, microsoft)
| 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
- Lyo.Api.Client (>= 3.0.0)
- Lyo.Api.Models (>= 3.0.0)
- Lyo.Exceptions (>= 3.0.0)
- Lyo.Http.Client (>= 3.0.0)
- Lyo.Query.Models (>= 3.0.0)
- Microsoft.EntityFrameworkCore (>= 10.0.5)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.5)
- Npgsql (>= 10.0.3)
NuGet packages (36)
Showing the top 5 NuGet packages that depend on Lyo.Seed:
| Package | Downloads |
|---|---|
|
Lyo.Audiobook.Seed
EF seed of audiobook genres, one series, and works with a narrator, an ISBN, and a chapter. |
|
|
Lyo.Billing.Seed
EF seed of billing clients, each with one draft invoice and one line. |
|
|
Lyo.Algorithms.Seed
EF seed of algorithm definitions, revisions, and labels. |
|
|
Lyo.PackageMetadata.Seed
EF seed of package metadata rows and stack prefixes. |
|
|
Lyo.Audit.Seed
EF seed of audit events and change rows. |
GitHub repositories
This package is not used by any popular GitHub repositories.