YesSql.Provider.CosmosDb 0.1.2

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

YesSql.Provider.CosmosDb

An Azure Cosmos DB (NoSQL API) storage provider for YesSql — the document-database layer used by Orchard Core.

Status: Orchard Core boots and runs on this provider (validated — see docs/ORCHARD-INTEGRATION.md and samples/OrchardSmokeTest), and YesSql's own conformance suite passes in full (249/249, 100%) — verified on both the PerTable and PerStore partition strategies against the Cosmos emulator. Document CRUD, map + reduce indexes (full lifecycle), single- and multi-index queries (incl. raw LEFT/RIGHT joins), ordering, paging, counts, IN-subqueries, SQL date/decimal functions, DDL, optimistic concurrency (version + ETag), and unit-of-work rollback (atomic in PerStore, best-effort in PerTable) all work end-to-end. The only structural limit is true cross-partition ACID, which Cosmos does not offer (PerStore makes a unit of work single-partition so its rollback is atomic). See docs/CONFORMANCE.md for the matrix, docs/CROSS-PARTITION-ACID.md for the partitioning/ACID model, and docs/ORCHARD-INTEGRATION.md for the Orchard wiring.

Why

YesSql ships first-party providers for SQL Server, PostgreSQL, MySQL, and SQLite only — all relational. This project closes the loop so YesSql (and therefore Orchard Core and any YesSql-based domain store) can run on Cosmos DB, enabling a single-Cosmos deployment topology.

Approach

This is a standalone NuGet package that depends on YesSql — not a fork. YesSql persists through an ADO.NET DbConnection (from IConnectionFactory) driven by SQL from ISqlDialect, so the provider supplies a co-designed pair:

  • a Cosmos-backed ADO.NET shim (DbConnection/DbCommand/DbDataReader/DbTransaction), and
  • an ISqlDialect that emits a constrained SQL surface the shim translates into Cosmos SDK operations.

Documents and index rows live as type-discriminated items in a single container, partitioned by their source table name. See docs/ARCHITECTURE.md.

Usage

using YesSql;
using YesSql.Provider.CosmosDb;
using Microsoft.Azure.Cosmos;

var configuration = new Configuration()
    .UseCosmosDb(new CosmosDbOptions
    {
        AccountEndpoint = "https://my-account.documents.azure.com:443/",
        AccountKey      = "<key>",
        DatabaseId      = "myapp",
        ContainerId     = "yessql",      // default
        PartitionKeyPath = "/pk",        // default
        // ClientOptions = ...           // only needed for the emulator (see below)
    })
    .UseDefaultIdGenerator();

var store = await StoreFactory.CreateAndInitializeAsync(configuration);

await using var session = store.CreateSession();
await session.SaveAsync(new Person { Name = "Alice" });
await session.SaveChangesAsync();

Local emulator

The provider is developed against the Azure Cosmos DB Linux emulator (vnext preview). Two gotchas:

  • The vnext emulator gateway serves HTTP on :8081, not HTTPS — use http://localhost:8081/.
  • Use ConnectionMode.Gateway + LimitToEndpoint = true, and accept the self-signed cert.
docker run -d --name cosmos-emu -p 8081:8081 -p 10250-10255:10250-10255 \
  mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
ClientOptions = new CosmosClientOptions
{
    ConnectionMode = ConnectionMode.Gateway,
    LimitToEndpoint = true,
    HttpClientFactory = () => new HttpClient(new HttpClientHandler
    {
        ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
    }),
}

Building and testing

dotnet build YesSql.Provider.CosmosDb.slnx

# Hand-written provider tests (need the emulator running)
dotnet test test/YesSql.Provider.CosmosDb.Tests

# YesSql's own conformance suite against Cosmos (see docs/CONFORMANCE.md)
dotnet test test/Conformance/YesSql.Provider.CosmosDb.Conformance.csproj

Targets

net8.0;net10.0 — matching YesSql 5.4.7.

Continuous integration

A ready-to-use GitHub Actions workflow (build + Cosmos emulator + tests + pack) lives at docs/github-actions-ci.yml. To enable it, copy it to .github/workflows/ci.yml and push (adding a workflow file requires a token with the workflow scope).

License

MIT — see LICENSE.

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 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.2 117 6/4/2026
0.1.1 109 6/4/2026
0.1.0 107 6/3/2026

0.1.2: fix paging regression — a bare OFFSET (.Skip without .Take) was dropped because Cosmos rejects OFFSET without LIMIT and the client-side fallback had been removed; now pairs a lone offset with a sentinel max LIMIT. Restores the full conformance suite to 249/249 (100%) on both PerTable and PerStore. 0.1.1: real-Azure-Cosmos correctness/scalability fixes found running a full Orchard Core setup against the classic (non-Postgres) emulator — (1) share a singleton CosmosClient per account instead of one per connection; (2) push OFFSET/LIMIT into Cosmos queries instead of trimming client-side; (3) provision database/container once per process, not on every connection open (control-plane ops are rate-limited on real Cosmos). 0.1.0: initial preview — ~92% of YesSql's conformance suite; Orchard Core boots and runs on Cosmos; PerTable and PerStore modes.