ข้ามไปยังเนื้อหา

Cephalon.Data.EntityFramework

เนื้อหานี้ยังไม่ได้แปลเป็นภาษาไทย แสดงเป็นภาษาอังกฤษแทน

Maturity: M2 · Ownership: cephalon-managed · Family: data-and-cdc · See audit, matrix.

Cephalon.Data.EntityFramework is the first provider-backed data companion pack for Cephalon.

  • registers Entity Framework Core DbContext services through companion-pack registration instead of host-specific startup code
  • supports either one shared DbContext or distinct read/write DbContext types for CQRS-oriented workloads
  • exposes an opt-in Entity Framework-backed inbox that persists processed inbound messages through the active write-side DbContext
  • exposes an opt-in Entity Framework-backed outbox that persists staged OutboxMessage rows through the active write-side DbContext
  • exposes an adapter-neutral Entity Framework-backed IEventDispatchStore for pending staged outbox rows when the eventing package is present
  • can enable official Sfid.EntityFramework conventions and save-time key assignment for typed Sfid identifiers
  • publishes capability metadata that makes the active provider and read/write DbContext roles introspectable
  • consumes Engine:Databases write/read role topology through the topology-aware registration overloads instead of inventing a second physical-layout contract
  • can execute startup schema apply for the registered write/read DbContext roles when Engine:Databases:Migrations:ApplyOnStartup is enabled
  • contributes first-class resolved database-role runtime state through IDatabaseRoleCatalog, /engine/database-roles, and snapshot.DatabaseRoles, including live connectivity plus pending-migration diagnostics for registered DbContext roles together with stable physical-target ids, display names, and physical co-location answers
  • honors the engine-owned RoleProbeFreshnessSeconds runtime contract for EF-backed role probes, including additive caching, explicit live-versus-cache metadata, and migration-state cache invalidation
  • contributes first-class database-migration descriptors and runtime state through IDatabaseMigrationCatalog, /engine/database-migrations, and snapshot.DatabaseMigrations
  • contributes operator-facing EF Core bundle/script/update command templates per migration target so deploy-time guidance stays attached to the same runtime catalog
  • publishes typed recommended migration ordering hints per logical target so operator playbooks can consume one engine-owned sequence instead of hardcoding write / read / history locally
  • contributes the resolved physical-target truth that lets the engine-owned migration playbook and topology posture surface physical-target execution groups, grouped command paths, combined command batches, and warnings when multiple EF-backed logical migration targets share one physical database and still need coordinated deploy-time execution
  • mirrors resolved-role runtime truth onto each migration descriptor through typed RoleHealthState, RoleHealthDescription, RoleMigrationState, RoleMigrationDescription, and RoleObservedAtUtc fields while preserving compatibility metadata for existing consumers
  • populates typed migration-command operator metadata such as ToolId, ExecutionCategory, and WorkingDirectoryHint on the shared DatabaseMigrationCommandDescriptor contract while preserving additive metadata for provider-specific details
  • provides the role-resolution and migration-registration primitives consumed by Cephalon.Audit.EntityFramework for the first durable history role follow-through
  • publishes an operator-facing inbox descriptor through /engine/inboxes and /engine/snapshot when the inbox path is enabled
  • publishes an operator-facing outbox descriptor through /engine/outboxes and /engine/snapshot when the outbox path is enabled, including the effective dispatch policy that currently owns or does not own staged-event execution
  • projects that same inbox through the event-driven-integration technology surface as inbox-stores when the eventing technology is active
  • projects that same outbox through the event-driven-integration technology surface as outbox-producers when the eventing technology is active
  • enables an outbox-backed IEventPublisher handoff path when the eventing technology is active and a truthful staged-publication path is available
  • Configuration/EntityFrameworkDataOptions.cs
  • Modeling/EntityFrameworkInboxEntry.cs
  • Modeling/IEntityFrameworkInboxContext.cs
  • Modeling/EntityFrameworkOutboxEntry.cs
  • Modeling/IEntityFrameworkOutboxContext.cs
  • Modeling/EntityFrameworkModelBuilderExtensions.cs
  • Registration/EntityFrameworkDataEngineBuilderExtensions.cs
  • Services/EntityFrameworkInboxRuntimeSurfaceContributor.cs
  • Services/EntityFrameworkEventDispatchStore.cs
  • Services/EntityFrameworkOutboxRuntimeSurfaceContributor.cs

This pack sits on top of Cephalon.Data, not in place of it. Cephalon.Data still owns the runtime-neutral IReadStore / IWriteStore dispatching surface, while Cephalon.Data.EntityFramework supplies the first concrete relational baseline that query and command handlers can depend on through standard Entity Framework Core DbContext injection.

The current slice is intentionally honest and narrow: it proves optional DbContext registration, CQRS-style read/write role separation, runtime capability metadata, topology-aware resolution from Engine:Databases, startup schema apply through a generic-host hosted service for the registered write and optional read DbContext roles, an opt-in inbox persistence path where the write-side DbContext explicitly implements IEntityFrameworkInboxContext and maps the shared processed-message entity with ConfigureCephalonInbox(), an opt-in outbox persistence path where the same write-side DbContext can implement IEntityFrameworkOutboxContext and map the shared outbox entity with ConfigureCephalonOutbox(), operator-facing inbox and outbox descriptors that make staged-only idempotency and delivery truth visible through the runtime introspection surface, an inbox-stores technology surface entry that describes application-managed idempotency stores when EventDrivenIntegration is active, an outbox-producers technology surface entry under the same technology selection, subscription metadata that can now say an application-managed inbox store is available without pretending the eventing pack dispatches through it, a staged-only outbox-backed IEventPublisher handoff path, an adapter-neutral Entity Framework-backed IEventDispatchStore that can read pending staged rows and persist dispatch_attempt_count, dispatched_at_utc, and next_attempt_at_utc follow-through for later adapter-owned dispatch loops, and an outbox descriptor that now moves truthfully between disabled, consumer-managed, and runtime-managed dispatch ownership as eventing packs are added. The same baseline now also understands the engine-owned UseRole contract for dependent targets, so Outbox and History can explicitly reuse the concrete write connection while still layering local schema or runtime overrides. Full subscription execution, arbitrary role graphs, and richer projection pipelines are still later slices.

The current recommendation is still not to turn DbContext inheritance into the primary engine contract. That contract now lives one layer higher: the engine ships Engine:Databases, projects it into AppProfile.Databases, and exposes the raw topology through /engine/databases, the resolved runtime role catalog through /engine/database-roles, and the resolved migration target catalog through /engine/database-migrations. Cephalon.Data.EntityFramework now consumes the engine-owned write and read role shape directly, supplies the shared role-resolution and migration-registration primitives used by Cephalon.Audit.EntityFramework, surfaces requested versus resolved role metadata when UseRole is active, publishes live connectivity plus pending-migration diagnostics through the engine-owned role catalog, and now also projects stable physical-target identity plus co-location so hosts and operator tooling can see when named or inline connection reuse points multiple logical roles at one physical database. The pack also honors the engine-owned RoleProbeFreshnessSeconds contract so probes can be cached additively per logical role with 0 as the explicit no-cache answer, a 30-second provider default when the engine contract does not override it, and a typed DatabaseRoleProbeDescriptor answer on DatabaseRoleRuntimeDescriptor.Probe plus DatabaseRoleDescriptor.Probe for stable cache/freshness/source timing. The older probeSource, probeFreshnessOrigin, probeFreshUntilUtc, and probeAgeSeconds metadata keys remain for additive compatibility and provider-specific details, but hosts and samples should now prefer the typed probe contract instead of parsing stable probe* keys locally. The pack also publishes planned/running/succeeded/failed migration truth through the engine-owned migration catalog instead of keeping that state inside a hosted service only, mirrors resolved-role runtime truth onto each logical migration target through typed role-runtime fields instead of forcing hosts to read only metadata keys, adds typed recommended execution order hints so hosts and samples can reuse one provider-published migration sequence, adds operator-facing dotnet ef bundle/script/update templates plus typed tool/category/working-directory metadata so the production bundle/script-first guidance stays attached to each logical migration target without forcing consumers to parse metadata dictionaries for every known field, and supplies the physical-target grouping truth that lets the engine-owned migration playbook plus topology posture surface physical-target execution groups, grouped command paths, combined command batches, and coordinated shared-database warnings instead of leaving samples to infer that risk locally. Dedicated outbox execution, broader role-reference graphs, and real combined execution artifacts for shared-target migrations are still later follow-through, but the first truthful history-role execution path plus dependent role references are now shipped. See Database topology.