Microsoft.Orleans.Clustering.AdoNet 10.4.0

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

Microsoft Orleans Clustering Provider for ADO.NET

Introduction

Microsoft Orleans Clustering Provider for ADO.NET allows Orleans silos to organize themselves as a cluster using relational databases through ADO.NET. This provider enables silos to discover each other, maintain cluster membership, and detect and handle failures.

Getting Started

To use this package, install it via NuGet:

dotnet add package Microsoft.Orleans.Clustering.AdoNet

You will also need to install the appropriate database driver package for your database system:

  • SQL Server: Microsoft.Data.SqlClient
  • MySQL: MySql.Data or MySqlConnector
  • PostgreSQL: Npgsql
  • Oracle: Oracle.ManagedDataAccess.Core
  • SQLite: Microsoft.Data.Sqlite

Example - Configuring ADO.NET Clustering

using Microsoft.Extensions.Hosting;
using Orleans.Configuration;
using Orleans.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;

// Define a grain interface
public interface IHelloGrain : IGrainWithStringKey
{
    Task<string> SayHello(string greeting);
}

// Implement the grain interface
public class HelloGrain : Grain, IHelloGrain
{
    public Task<string> SayHello(string greeting)
    {
        return Task.FromResult($"Hello, {greeting}!");
    }
}

var builder = Host.CreateApplicationBuilder(args)
    .UseOrleans(siloBuilder =>
    {
        siloBuilder
            // Configure ADO.NET for clustering
            .UseAdoNetClustering(options =>
            {
                options.Invariant = "System.Data.SqlClient";  // Or other providers like "MySql.Data.MySqlClient", "Npgsql", etc.
                options.ConnectionString = "Server=localhost;Database=OrleansCluster;User Id=myUsername;******;";
            });
    });

var host = builder.Build();
await host.StartAsync();

// Get a reference to a grain and call it
var client = host.Services.GetRequiredService<IClusterClient>();
var grain = client.GetGrain<IHelloGrain>("user123");
var response = await grain.SayHello("World");

// Print the result
Console.WriteLine($"Grain response: {response}");

// Keep the host running until the application is shut down
await host.WaitForShutdownAsync();

Example - Configuring Client to Connect to Cluster

using Microsoft.Extensions.Hosting;
using Orleans;
using Orleans.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;

// Define a grain interface
public interface IHelloGrain : IGrainWithStringKey
{
    Task<string> SayHello(string greeting);
}

var clientBuilder = Host.CreateApplicationBuilder(args)
    .UseOrleansClient(clientBuilder =>
    {
        clientBuilder
            // Configure the client to use ADO.NET for clustering
            .UseAdoNetClustering(options =>
            {
                options.Invariant = "Microsoft.Data.SqlClient";  // Or other providers like "MySql.Data.MySqlClient", "Npgsql", etc.
                options.ConnectionString = "Server=localhost;Database=OrleansCluster;User Id=myUsername;******;";
            });
    });

var host = clientBuilder.Build();
await host.StartAsync();
var client = host.Services.GetRequiredService<IClusterClient>();

// Get a reference to a grain and call it
var grain = client.GetGrain<IHelloGrain>("user123");
var response = await grain.SayHello("World");

// Print the result
Console.WriteLine($"Grain response: {response}");

// Keep the host running until the application is shut down
await host.WaitForShutdownAsync();

Database Setup

Before using the ADO.NET clustering provider, you need to set up the necessary database tables. Scripts for different database systems are available in the Orleans source repository: namespace ExampleGrains;

Optional membership SQL enhancements

Each silo owns its heartbeat. A heartbeat is one primary-key-targeted assignment to IAmAliveTime, sent as a single database command. Heartbeats preserve the logical membership row and table tokens, so a membership update can use tokens captured before a heartbeat. Canonical membership consistency is governed by those logical tokens; heartbeat timestamps are best-effort liveness observations.

Upgrading silos or ADO.NET gateway-discovery clients preserves support for existing query installations. Database updates are optional. With an existing catalog, cleanup continues using its installed CleanupDefunctSiloEntriesKey query and behavior.

The existing *-Clustering.sql installation scripts include improved conditional-write rollback and Dead-row cleanup. Their optional CleanupDefunctSiloEntryKey enables cleanup based on the latest start, heartbeat, and suspicion timestamps, with a captured-row condition protecting concurrent changes. Fresh installations receive these definitions through the usual database setup.

SQL Server joined membership reads use statement snapshots provided by READ_COMMITTED_SNAPSHOT, which the existing SQLServer-Main.sql setup enables.

Providers load and cache queries during initialization. Existing deployments continue using their installed definitions. Operators choosing to adopt revised definitions can use their normal database change-management process; reinitialize providers afterward to load the revised catalog. The original query keys and parameter sets remain supported.

The SQL enhancements take effect per process as it adopts the updated queries. Until then, cached SQL Server/MySQL updates retain their previous missing-row version-increment behavior, and cached cleanup retains its previous status filter. The enhanced behavior applies cluster-wide once all membership writers use those definitions. SQL Server and MySQL inserts retain the original row-then-version statement order.

Documentation

For more comprehensive documentation, please refer to:

Feedback & Contributing

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 (34)

Showing the top 5 NuGet packages that depend on Microsoft.Orleans.Clustering.AdoNet:

Package Downloads
Microsoft.Orleans.OrleansSqlUtils

Library of utility types for relational storage of Microsoft Orleans

Aksio.Cratis.Extensions.Orleans

Package Description

KingMetal.Domains.Abstractions

Package Description

Mtl.Infrastructures.Workers

主要是封装了下Netty服务器和客户端的方法,提供了简单的方法调用就能启动Netty服务器和客户端,封装了Orleans的服务器和客户端的启动和连接方法,使操作简单,减少重复的代码

Aksio.Cratis.Kernel.Orleans

Package Description

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Microsoft.Orleans.Clustering.AdoNet:

Repository Stars
J-Tech-Japan/Sekiban
Sekiban - an Opinionated Event Sourcing and CQRS Framework using C#. It can store data into Azure Cosmos DB, AWS Dynamo DB or Postgres
shinyorg/templates
dotnet CLI & Visual Studio Templates
usnistgov/ACVP-Server
A repository tracking releases of NIST's ACVP server. See www.github.com/usnistgov/ACVP for the protocol.
Version Downloads Last Updated
10.4.0 22,752 10/3/2026
10.3.1 45,504 8/28/2026
10.3.0 2,226 8/27/2026
10.3.0-rc.1 109 8/25/2026
10.2.2 64,172 7/21/2026
10.2.2-rc.2 156 7/15/2026
10.2.2-rc.1 151 7/10/2026
10.2.1 32,302 6/24/2026
10.2.1-preview.1 145 6/19/2026
10.2.0 15,394 6/12/2026
10.1.1-preview.1 139 5/13/2026
10.1.0 168,372 4/14/2026
10.0.1 91,202 2/7/2026
10.0.0 32,111 1/20/2026
10.0.0-rc.2 730 12/31/2025
9.2.1 204,475 7/16/2025
9.2.0 2,404 7/14/2025
9.2.0-preview3 663 6/10/2025
9.2.0-preview2 337 6/4/2025
3.8.1 38,167 4/24/2026
Loading failed