YesSql.Provider.CosmosDb 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package YesSql.Provider.CosmosDb --version 0.1.0
                    
NuGet\Install-Package YesSql.Provider.CosmosDb -Version 0.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="YesSql.Provider.CosmosDb" Version="0.1.0" />
                    
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.0" />
                    
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.0
                    
#r "nuget: YesSql.Provider.CosmosDb, 0.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 YesSql.Provider.CosmosDb@0.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=YesSql.Provider.CosmosDb&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=YesSql.Provider.CosmosDb&version=0.1.0
                    
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 ~92% of YesSql's own conformance suite passes (229/249). Document CRUD, map + reduce indexes (full lifecycle), single- and multi-index queries, ordering, paging, counts, IN-subqueries, optimistic concurrency (version + ETag), and unit-of-work rollback (atomic in PerStore, best-effort in PerTable) work end-to-end against the Cosmos emulator. The remaining gaps are non-Orchard operations (raw LEFT/RIGHT joins, SQL date/decimal functions, DDL) or Cosmos-bounded niceties. 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 119 6/4/2026
0.1.1 110 6/4/2026
0.1.0 110 6/3/2026

Initial preview. ~92% of YesSql's conformance suite; Orchard Core boots and runs on Cosmos. PerTable (scalable) and PerStore (single-partition, atomic rollback) modes.