CoreEx.Cosmos 4.1.0

dotnet add package CoreEx.Cosmos --version 4.1.0
                    
NuGet\Install-Package CoreEx.Cosmos -Version 4.1.0
                    
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="CoreEx.Cosmos" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreEx.Cosmos" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="CoreEx.Cosmos" />
                    
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 CoreEx.Cosmos --version 4.1.0
                    
#r "nuget: CoreEx.Cosmos, 4.1.0"
                    
#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 CoreEx.Cosmos@4.1.0
                    
#: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=CoreEx.Cosmos&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=CoreEx.Cosmos&version=4.1.0
                    
Install as a Cake Tool

CoreEx.Cosmos

Provides the core Azure Cosmos DB access layer: ICosmosDb/CosmosDb as the CoreEx-Cosmos bridge, CosmosDbContainer<TModel> and CosmosDbMappedContainer<TValue, TModel, TMapper> for typed CRUD + query operations, CosmosDbQuery<TModel> as the composable, invoker-wrapped query/materialization type, CosmosDbInvoker for structured operation logging and exception mapping, a CosmosDbUnitOfWork transactional outbox (TransactionalBatch-based), and a Change Feed Processor-based outbox relay.

Overview

CoreEx.Cosmos wraps the Microsoft.Azure.Cosmos SDK with the same CoreEx data conventions used elsewhere in the framework: ETag/optimistic-concurrency checking (via Cosmos DB's native If-Match semantics), multi-tenancy filtering, logical-delete filtering, type-discriminator filtering (for several business model types sharing one container/partition), change-log stamping, PagingArgs paging, and Result<T> (Railway-Oriented Programming) pipeline integration.

The central type is CosmosDb, which holds the CosmosClient/Database and exposes Container<TModel>(id, configure?) as the entry point for all strongly-typed CRUD. CosmosDbContainer<TModel> provides GetAsync, CreateAsync, UpdateAsync, DeleteAsync, UpsertAsync, and Query (returning a CosmosDbQuery<TModel>) β€” each applying the applicable CoreEx cross-cutting pipeline. CosmosDbMappedContainer<TValue, TModel, TMapper> adds an IBiDirectionMapper layer for use cases where the Cosmos document model type differs from the domain entity type.

The Outbox sub-namespace implements the Transactional Outbox pattern for Cosmos DB: CosmosDbUnitOfWork enlists business mutations and outbox event documents into the same TransactionalBatch (Cosmos DB's only atomic multi-operation primitive - atomic within a single container/logical partition key only), so the write is genuinely all-or-nothing without a separate outbox table. A Change Feed Processor-based relay (CosmosDbOutboxRelay) then decodes, publishes, and cleans up these documents, self-pausing/self-resuming via a circuit breaker on sustained publish failure.

This is a sibling package to CoreEx.Database/CoreEx.Database.SqlServer/CoreEx.Database.Postgres, not a provider underneath CoreEx.Database β€” Cosmos DB is a document store with no ADO.NET-shaped connection/transaction/parameter surface, so it warrants its own package family while still sharing the same ergonomic CRUD/ROP/paging conventions, and (for the outbox relay specifically) the same harmonized metric names and shared trace-linking helper as CoreEx.Database.SqlServer/CoreEx.Database.Postgres.

This package provides the core CRUD + query access layer, a TransactionalBatch-based transactional outbox (CosmosDbUnitOfWork/CosmosDbEventPublisher), and a Change Feed Processor-based outbox relay (CosmosDbOutboxRelay) - happy path only. Not included: poison-message/dead-letter handling for the relay (a permanently-failing outbox document is redelivered forever by the Change Feed Processor's own native backoff, with no built-in give-up - to be designed as one shared pattern across the SQL Server/Postgres/Cosmos relays, not Cosmos-specific), a multi-query (IMultiQueryArgs) equivalent, and any EF Core-Cosmos integration.

Key capabilities

  • πŸ”— Cosmos DB bridge: CosmosDb wraps a DI-resolved CosmosClient (typically registered via Aspire's builder.AddAzureCosmosClient("Cosmos")) and caches both raw SDK Container instances (per container id) and CosmosDbContainer<TModel> instances (per (containerId, TModel) pair - not container id alone, since a container may legitimately host more than one type-discriminated model).
  • πŸ“– Typed CRUD: CosmosDbContainer<TModel> provides GetAsync, CreateAsync, UpdateAsync, DeleteAsync, UpsertAsync with automatic ETag/concurrency validation (native Cosmos DB If-Match), tenant isolation, and logical-delete handling.
  • πŸ” Mapped CRUD: CosmosDbMappedContainer<TValue, TModel, TMapper> layers an IBiDirectionMapper<TValue, TModel> over CosmosDbContainer<TModel>, mapping between the domain entity type and the Cosmos DB document model type transparently for all CRUD operations.
  • πŸ” Composable query: CosmosDbContainer<TModel>.Query(query?, args?) returns a CosmosDbQuery<TModel> β€” a dedicated wrapper (not a bare IQueryable<TModel>) constructed over Container.GetItemLinqQueryable<TModel>(); additional filtering/ordering is composed via the query delegate (standard LINQ Where/OrderBy), and any WithTenantFilter/WithLogicalDeleteFilter/WithTypeDiscriminator predicates from CosmosDbModelOptions are applied automatically (see CosmosDbQuery<TModel>.AsQueryable(CosmosDbArgs?), with an optional CosmosDbArgs.BypassFilters override).
  • πŸ“„ Invoker-wrapped materializers: CosmosDbQuery<TModel> provides instance-method materializers β€” ToListAsync, ToCollectionAsync<TColl>, ToItemsResultAsync, SingleAsync/SingleOrDefaultAsync/FirstAsync/FirstOrDefaultAsync, ToMappedItemsAsync, ToMappedItemsResultAsync (plus a WithResultAsync ROP counterpart for each) β€” using Skip/Take (translated by the Cosmos DB LINQ provider to OFFSET…LIMIT) via WithPaging(PagingArgs?). Being instance methods on CosmosDbQuery<TModel> rather than IQueryable<T> extensions, they structurally cannot collide with CoreEx.EntityFrameworkCore's identically-named EfDbExtensions (see AGENTS.md), and every materializer routes through CosmosDbInvoker for structured logging and CosmosException mapping.
  • 🏷️ ETag / concurrency: for an UpdateAsync, the model's IETag.ETag is mapped into ItemRequestOptions.IfMatchEtag (where CosmosDbArgs.AutoMapETag is true, the default); Cosmos DB enforces the optimistic-concurrency check server-side and returns a 412 Precondition Failed, which CosmosDbInvoker converts to a ConcurrencyException/Result.ConcurrencyError.
  • 🧠 Change tracker: a per-scope snapshot cache (ICosmosDb.ChangeTracker) makes repeat point GetAsync calls free of RU cost; UpdateAsync pre-reads to copy back server-managed values (created audit, unmapped additional properties) and skips the write when nothing changed (DataResult.WasMutated == false). Opt out per call with CosmosDbArgs.ClearChangeTrackerAfterGet; cleared when the root unit-of-work transaction ends. Per-document version checks prevent in-flight reads from repopulating snapshots after eviction or clearing; immediate writes also evict on completion. Needs UseSystemTextJsonSerializerWithOptions.
  • πŸ”’ Multi-tenancy: non-query operations automatically reject a mismatched IReadOnlyTenantId.TenantId as not-found; Query() only applies the equivalent TenantId == executionContext.TenantId predicate when CosmosDbModelOptions.WithTenantFilter() has been configured.
  • πŸ—‘οΈ Logical delete: entities implementing ILogicallyDeleted are soft-deleted (IsDeleted = true via a read-modify-ReplaceItemAsync) on DeleteAsync rather than physically removed; a physical DeleteAsync is idempotent (a 404 is not an error).
  • 🏷️ Type discriminator (multi-type containers): CosmosDbModelOptions<TModel>.WithTypeDiscriminator() reuses the existing ITypeDiscriminator/IReadOnlyTypeDiscriminator hook (auto-populated by Model.PrepareCreate/PrepareUpdate) to let several business model types safely share one container/partition β€” no envelope/wrapper type required.
  • ⏳ Time-to-live: CosmosDbModelOptions<TModel>.WithTimeToLive(Func<TModel, int?>) computes and applies a document's ttl on CreateAsync/UpdateAsync (requires TModel to implement the mutable ITimeToLive β€” Cosmos DB's ttl is a document-body field, not a separate SDK request option, so a computed value can only take effect by being written back onto the model). Where not configured, a model's own ITimeToLive.TimeToLive value (if any) simply serializes through as-is; ITimeToLive/IReadOnlyTimeToLive live in core CoreEx.Data (alongside IPartitionKey/ITypeDiscriminator) for reuse by a future non-Cosmos NoSQL package.
  • πŸ“š Reference data: CosmosDbReferenceData provides CreateAsync/UpdateAsync/ActivateAsync/DeactivateAsync/DeleteAsync for reference data (Cosmos counterpart of EfDbReferenceData); wired up by CoreEx.CodeGen when a repository: Cosmos entity sets mutability.
  • πŸ”‘ Fixed partition key: CosmosDbModelOptions<TModel>.WithFixedPartitionKey(string?) configures one constant partition key value for the whole container β€” suitable for small, bounded containers where partitioning isn't meaningful (Cosmos DB's own guidance: a container well under the 20 GB/10,000 RU/s per-logical-partition limits typically needs only one or two physical partitions regardless of partition key cardinality). It also defaults GetAsync/DeleteAsync's partitionKey parameter (now optional) when the caller omits it β€” WithPartitionKey(Func<TModel, string?>)'s per-model function cannot do this, since Get/Delete have no model instance to invoke it against. The two are mutually exclusive (configuring both throws InvalidOperationException), and either always wins over β€” but must not silently disagree with β€” a non-null value the model already carries via IReadOnlyPartitionKey (a genuine mismatch throws rather than being overridden, since Cosmos DB itself requires the document body's partition-key-path value to agree with the value supplied for the operation).
  • πŸ“ Structured logging: CosmosDbInvoker wraps every CRUD CosmosDb operation with structured log entries (tracing/Activity spans are intentionally disabled via IsTracingDisabled - CRUD is high-frequency) and converts CosmosException into the corresponding CoreEx exception (NotFoundException/DuplicateException/ConcurrencyException). The outbox relay's CosmosDbOutboxRelayInvoker (Outbox sub-namespace) is a separate, tracing-enabled invoker - relay batch processing is comparatively low-frequency and specifically where distributed-tracing visibility matters most.
  • πŸ”„ Transactional outbox: CosmosDbUnitOfWork implements IUnitOfWork, enlisting CosmosDbContainer<TModel> Create/Update/Delete calls made within its TransactionAsync scope into one ambient TransactionalBatch (client-side fail-fast if two enlisted operations target different containers/partition keys); CosmosDbEventPublisher (an IEventPublisher) enlists outbox event documents into the same batch, so the business mutation and its event are atomic without a separate outbox table. Outbox documents are auto-excluded from ordinary business queries via a reserved $outbox id-prefix (no opt-in required). IUnitOfWork.SynchronizeETag<T> resolves a mapped contract's true, server-assigned ETag after the batch commits (deferred execution means it isn't known upfront) by correlating on CompositeKey, not object reference.
  • πŸ“€ Outbox relay: CosmosDbOutboxRelay/CosmosDbOutboxRelayProcessor (Outbox sub-namespace) consume outbox event documents via a Cosmos DB Change Feed Processor (push-based, SDK-managed - not a polling loop like the SQL Server/Postgres relay), decode/publish/cleanup-delete each batch, and self-pause/self-resume via a CircuitBreakerResiliency<TOwner>-based circuit breaker on a sustained publish-failure ratio. Register via builder.AddCosmosDbOutboxRelayHostedService(containerId, servicesCount?) - one call per outbox-hosting container, each with its own concurrency count. This registers the relay only; a genuine destination IEventPublisher (e.g. Azure Service Bus, matching the SQL Server/Postgres samples) must also be registered - see AGENTS.md. CosmosDbEventPublisher (the write-side publisher, above) must never be registered for this role; CosmosDbOutboxRelayProcessor.ProcessBatchAsync detects that misconfiguration and throws immediately with an actionable message rather than failing deeper inside the publish call.
  • πŸ“Š Outbox metrics: CosmosMetrics exposes .NET Meter instruments harmonized with SqlServerMetrics/PostgresMetrics: cosmos.outbox.enqueue (counter), cosmos.outbox.relay.publish and cosmos.outbox.relay.publish.failed (counters), cosmos.outbox.relay.oldest_lag and cosmos.outbox.relay.newest_lag (histograms in ms), plus Cosmos-specific cosmos.outbox.relay.cleanup.deleted/cosmos.outbox.relay.cleanup.failed (the relay's own post-publish document cleanup has no SQL Server/Postgres equivalent).
  • πŸ“₯ Batch import & container provisioning: CosmosDbBatch.ImportBatchAsync(Async)/ImportDiscriminatedBatchAsync load raw JSON directly into a Container/Database (no CoreEx.Cosmos model type involved); CosmosDbContainerExtensions.ReplaceOrCreateContainerAsync/DeleteContainerIfExistsAsync provision or reset a container from code. Neither depends on the rest of this package - useful for data seeding, bulk/one-off loads, and migrations alike. On top of these, CoreEx.Cosmos.Provisioning (CosmosDbProvisioner, CosmosDbConsole, CosmosDbProvisionArgs) provides a reusable, DbEx-style Drop/Create/Reset/Data migration console for dev/test - see Contoso.Customers.Database.
  • 🧩 Multi-set queries: ICosmosDb.SelectMultiSetAsync/SelectMultiSetWithResultAsync(containerId, MultiSetOptions, cancellationToken?) (Extended namespace) read multiple, type-discriminator-keyed sets of documents from the same container/partition in one round-trip - the Cosmos DB equivalent of CoreEx.Database.Extended's positional/ordered multi-set queries, adapted for a discriminator-keyed (not positional) demux. MultiSetSingleArgs<TModel>/MultiSetCollArgs<TColl, TModel> accumulate matching documents (each per-item tenant/logical-delete/additive-filter-checked via CosmosDbContainer<TModel>.CheckModel); TModel must implement IReadOnlyTypeDiscriminator. The type-discriminator's JSON property name is resolved once per call from the ambient CosmosClientOptions.UseSystemTextJsonSerializerWithOptions naming policy (e.g. camelCase). Co-located outbox event documents are always excluded server-side; where a model's CosmosDbModelOptions<TModel>.WithTenantFilter/WithLogicalDeleteFilter is configured, an additional defensive, IS_DEFINED-guarded SQL predicate is layered in as a server-side (RU/bandwidth) optimization - never excluding a document purely for predating the property. MultiSetOptions.Args.QueryRequestOptions, where supplied, takes precedence over one built from MultiSetOptions.PartitionKey (a genuine mismatch between the two throws ArgumentException). SelectMultiSetWithResultAsync returns a Result (Railway-Oriented Programming) only for a genuine business/domain-level outcome (a mapped CosmosException, or a WithFilter authorization-style denial) - MinimumRows/MaximumRows/malformed-response/argument-validation conditions remain plain exceptions even from this method, consistent with Result being reserved for expected errors, not exceptions; SelectMultiSetAsync is a thin ThrowOnError() wrapper over it. See AGENTS.md for the full mechanism.

Outbox tracing defaults mirror the relational relays: background change-feed polling, lease maintenance, and cleanup SDK/HTTP spans are suppressed, while publishing spans and originating-trace relay markers remain enabled. Metrics and warning/error logs remain available. Set CosmosDbOutboxRelayOptions.IsInstrumentationEnabledForPolling to true before start/resume to diagnose background processing; CosmosDbOutboxRelayProcessor.IsInstrumentationEnabledForPublishing independently controls publishing instrumentation (default true).

Key types

Type Description
ICosmosDb / CosmosDb CoreEx Cosmos DB bridge: holds CosmosClient, Database, CosmosDbOptions, ExecutionContext, ambient CurrentTransaction (for CosmosDbUnitOfWork); exposes Container<TModel>(containerId, configure?) entry point; caches Container (per containerId) and CosmosDbContainer<TModel> (per (containerId, TModel)) instances; maps CosmosException via HandleCosmosException.
CosmosDbContainer<TModel> Strongly-typed CRUD + query for a single Cosmos DB model type: GetAsync, CreateAsync, UpdateAsync, DeleteAsync, UpsertAsync, Query(query?, args?); applies the applicable CoreEx cross-cutting pipeline; transparently enlists into an ambient CosmosDbUnitOfWork transaction where one is active.
CosmosDbMappedContainer<TValue, TModel, TMapper> Adds an IBiDirectionMapper<TValue, TModel> layer over CosmosDbContainer<TModel> for domain entity ↔ Cosmos DB document model conversion; provides GetAsync, CreateAsync, UpdateAsync, DeleteAsync, UpsertAsync.
CosmosDbQuery<TModel> Composable, invoker-wrapped query type returned by CosmosDbContainer<TModel>.Query(query?, args?): AsQueryable(args?), WithPaging(paging?), and materializers ToListAsync, ToCollectionAsync<TColl>, ToItemsResultAsync, SingleAsync/SingleOrDefaultAsync/FirstAsync/FirstOrDefaultAsync, ToMappedItemsAsync, ToMappedItemsResultAsync (each with a WithResultAsync ROP counterpart).
CosmosDbArgs Per-operation options: NullOnNotFound, AutoMapETag, Refresh, ItemRequestOptions, QueryRequestOptions; defaults sourced from CosmosDbModelOptions<TModel>.Args then CosmosDbOptions.Args.
CosmosDbOptions Instance-level options for ICosmosDb (typically a singleton): default CosmosDbArgs, per-(containerId, TModel) options registry via GetOrAddModelOptions<TModel>(containerId).
CosmosDbModelOptions<TModel> Per-container/model configuration: WithArgs, WithGetKey, WithFormatIdentifier, WithPartitionKey, WithFixedPartitionKey, WithTimeToLive, WithTenantFilter, WithLogicalDeleteFilter, WithTypeDiscriminator.
CosmosDbInvoker InvokerBase<ICosmosDb, CosmosDbArgs> emitting structured log entries for every CRUD CosmosDb operation (tracing intentionally disabled); catches CosmosException and folds into Result/Result<T> failures for ROP callers; also orchestrates CosmosDbUnitOfWork transaction commit/outbox-publish/exception-mapping.
CosmosDbModelBase Optional convenience abstract base implementing IIdentifier<string>, IETag, IPartitionKey, ITimeToLive using the Cosmos DB reserved system property names (id, _etag, ttl).
CosmosDbTransaction The ambient ordinal-to-CompositeKey tracked TransactionalBatch scope bound to CosmosDbUnitOfWork.TransactionAsync - first enlisted operation binds the container/partition key; a mismatched later operation throws client-side, before any network call.
CosmosDbBatch Raw-JSON (JsonArray/JsonObject) batch-import extensions (ImportBatchAsync, ImportDiscriminatedBatchAsync) over Container/Database - no CoreEx.Cosmos model type involved, so a caller controls the exact document shape (partition key, type-discriminator value) directly; suited to data seeding, bulk/one-off loads, and migrations alike.
CosmosDbContainerExtensions Container lifecycle extensions (ReplaceOrCreateContainerAsync, DeleteContainerIfExistsAsync) over raw Database/ContainerProperties - no dependency on any other CoreEx.Cosmos type; useful for provisioning or resetting a database/container from code.
IMultiSetArgs / IMultiSetArgs<TModel> Discriminator-keyed multi-set query contract (Extended): ModelType, ResolveTypeDiscriminator(cosmosDb, containerId) (resolves TModel's configured CosmosDbModelOptions<TModel>.EffectiveTypeDiscriminator), AddItem, BuildFilterClause (builds a defensive, IS_DEFINED-guarded tenant/logical-delete SQL predicate where WithTenantFilter/WithLogicalDeleteFilter is configured); extends the shared CoreEx.Data.IMultiSetArgsCore (MinimumRows, MaximumRows, StopOnNull, InvokeResult).
MultiSetOptions Bundles a multi-set query's per-call inputs (PartitionKey, Args, MultiSetArgs) into one record, avoiding an ever-growing method-parameter list as new capabilities are added.
MultiSetSingleArgs<TModel> / MultiSetCollArgs<TColl, TModel> Concrete IMultiSetArgs<TModel> implementations (Extended) for a single item or a collection of items respectively; guard (via a static constructor) that TModel implements IReadOnlyTypeDiscriminator.
CosmosDbMultiSetExtensions ICosmosDb.SelectMultiSetAsync/SelectMultiSetWithResultAsync(containerId, MultiSetOptions, ...) (Extended) - the multi-set query engine: resolves the discriminator JSON property name, builds/executes a raw stream query (honoring each IMultiSetArgs.BuildFilterClause and a CosmosDbArgs.QueryRequestOptions precedence rule), demuxes/deserializes/filters/accumulates per document, then validates MinimumRows/MaximumRows and invokes InvokeResult() per IMultiSetArgs, in supplied order, honoring StopOnNull. SelectMultiSetAsync is a ThrowOnError() wrapper over the Result-returning SelectMultiSetWithResultAsync.
CosmosDbUnitOfWork IUnitOfWork implementation for ICosmosDb: TransactionAsync orchestration, optional Outbox (IEventPublisher, typically CosmosDbEventPublisher), and SynchronizeETag<T> to resolve a mapped contract's true post-commit ETag by CompositeKey.
CosmosDbEventPublisher EventPublisherBase that enlists outbox event documents (CosmosDbOutboxEvent) into the active CosmosDbUnitOfWork's ambient TransactionalBatch - same container/partition as the paired business mutation, since a dedicated outbox container/table isn't possible while preserving atomicity.
CosmosDbOutboxEvent The outbox event document shape (Id, PartitionKey, Destination, Event as JsonElement, TimeToLive); identified by a reserved $outbox Id prefix, auto-excluded from ordinary business queries against the same container.
CosmosDbOutboxRelay Owns the Change Feed Processor for one monitored container: start/pause/resume/stop lifecycle, circuit-breaker-wrapped batch processing via CosmosDbOutboxRelayProcessor.
CosmosDbOutboxRelayProcessor Pure filter/decode/publish/cleanup-delete batch logic, with no Change Feed Processor SDK dependency - directly unit-testable by handing it a batch of CosmosDbOutboxEvent documents.
CosmosDbOutboxRelayHostedService Thin HostedServiceBase wrapper delegating to CosmosDbOutboxRelay; registered via AddCosmosDbOutboxRelayHostedService(containerId, servicesCount?).
CosmosMetrics Static .NET Meter with counters/histograms for outbox enqueue throughput and relay publish/cleanup/lag, harmonized with SqlServerMetrics/PostgresMetrics.

Namespaces

Namespace Description
(root) Core CRUD + query access layer: CosmosDb, CosmosDbContainer<TModel>, CosmosDbMappedContainer, CosmosDbQuery<TModel>, CosmosDbModelOptions<TModel>.
Extended CosmosDbInvoker, CosmosDbTransaction, CosmosDbHealthCheck, and CosmosDbUnitOfWorkInvoker - orchestrates CosmosDbUnitOfWork transaction commit via CosmosDbInvoker, mirroring CoreEx.Database's SqlServerUnitOfWorkInvoker/PostgresUnitOfWork split of responsibility. Also CosmosDbBatch/CosmosDbContainerExtensions - raw-JSON batch import and container lifecycle helpers with no dependency on the rest of this package. Also IMultiSetArgs/IMultiSetArgs<TModel>/MultiSetSingleArgs<TModel>/MultiSetCollArgs<TColl, TModel>/CosmosDbMultiSetExtensions - the discriminator-keyed multi-set query capability.
Outbox Transactional outbox write side (CosmosDbEventPublisher, CosmosDbOutboxEvent) and relay (CosmosDbOutboxRelay, CosmosDbOutboxRelayProcessor, CosmosDbOutboxRelayOptions, CosmosDbOutboxRelayResiliency, CosmosDbOutboxRelayInvoker, CosmosDbOutboxRelayHostedService).
  • CoreEx.Data - IUnitOfWork, PagingArgs, ItemsResult<T>, DataResult, IPartitionKey/IReadOnlyPartitionKey, ITenantId, ILogicallyDeleted, ITypeDiscriminator, Model (PrepareCreate/PrepareUpdate), IMultiSetArgsCore (shared base for Extended.IMultiSetArgs's discriminator-keyed multi-set queries) β€” all reused as-is, unchanged; CosmosDbUnitOfWork implements IUnitOfWork directly (not a Cosmos-specific sub-interface), keeping application-layer services provider-agnostic.
  • CoreEx.Mapping - IBiDirectionMapper<TSource, TDestination> is the mapper contract used by CosmosDbMappedContainer.
  • CoreEx.EntityFrameworkCore - the closest structural analogue (EfDb/EfDbModel/EfDbMappedModel); CosmosDbContainer<TModel> mirrors EfDbModel<TModel>'s CRUD/ROP shape, adapted to the Cosmos DB SDK.
  • CoreEx.Invokers - CosmosDbInvoker and CosmosDbOutboxRelayInvoker extend InvokerBase for structured logging/tracing.
  • CoreEx.Events - IEventPublisher/EventPublisherBase (CosmosDbEventPublisher's base), CloudEventTracingExtensions.LinkTraceContext (used by the relay to connect its publish span back to each original producer's trace), and EventFormatter's CloudEvents conversion, shared unchanged with CoreEx.Database's outbox relay.
  • CoreEx.Hosting - HostedServiceBase, CircuitBreakerResiliency<TOwner> (the relay's self-pause/self-resume mechanism, shared with CoreEx.Azure.Messaging.ServiceBus's receiver), ResilienceOwner<TOwner>.
  • CoreEx.Database - the relational sibling family's equivalent outbox relay (DatabaseOutboxRelayBase); Cosmos DB's Change Feed Processor-based push model is deliberately structured differently (mirroring the Azure Service Bus receiver instead), but shares metric naming and trace-linking with it.

Additional Resources

AI Usage Guide

An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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 CoreEx.Cosmos:

Package Downloads
CoreEx.UnitTesting

Core .NET extensions and abstractions for the testing of backend services.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on CoreEx.Cosmos:

Repository Stars
Avanade/Beef
The Business Entity Execution Framework (Beef) framework, and the underlying code generation, has been primarily created to support the industrialization of API development.
Version Downloads Last Updated
4.1.0 85 10/12/2026
4.0.0 139 9/21/2026
3.31.0 596 2/1/2025
3.30.2 293 12/11/2024
3.30.1 256 12/9/2024
3.30.0 336 11/21/2024
3.29.0 271 11/19/2024
3.28.0 286 11/9/2024
3.27.3 339 10/23/2024
3.27.2 298 10/17/2024
3.27.1 355 10/15/2024
3.27.0 290 10/11/2024
3.26.0 287 10/3/2024
3.25.6 352 10/2/2024
3.25.5 324 9/25/2024
3.25.4 293 9/24/2024
3.25.3 290 9/18/2024
3.25.2 308 9/17/2024
3.25.1 405 9/16/2024
3.25.0 331 9/10/2024
Loading failed