Microsoft.Orleans.Clustering.AdoNet 9.2.1

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

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 was computed.  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 (23)

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

Package Downloads
Aksio.Cratis.Extensions.Orleans

Package Description

Microsoft.Orleans.OrleansSqlUtils

Library of utility types for relational storage of Microsoft Orleans

KingMetal.Domains.Abstractions

Package Description

Mtl.Infrastructures.Workers

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

Aksio.Cratis.Kernel.Orleans

Package Description

GitHub repositories (2)

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

Repository Stars
axzxs2001/Asp.NetCoreExperiment
原来所有项目都移动到**OleVersion**目录下进行保留。新的案例装以.net 5.0为主,一部分对以前案例进行升级,一部分将以前的工作经验总结出来,以供大家参考!
shinyorg/templates
dotnet CLI & Visual Studio Templates
Version Downloads Last Updated
9.2.1 65,173 7/16/2025
9.2.0 1,399 7/14/2025
9.2.0-preview3 593 6/10/2025
9.2.0-preview2 250 6/4/2025
9.2.0-preview1 396 4/4/2025
9.1.2 78,700 2/13/2025
9.0.1 37,599 11/23/2024
9.0.0 3,685 11/14/2024
8.2.0 248,734 7/12/2024
8.2.0-preview1 386 5/22/2024
8.1.0 78,809 4/17/2024
8.1.0-preview3 300 3/11/2024
8.1.0-preview2 241 2/23/2024
8.1.0-preview1 178 2/13/2024
8.0.0 63,787 1/5/2024
8.0.0-rc2 1,011 12/20/2023
8.0.0-rc1 401 12/4/2023
7.2.7 7,368 10/15/2024
7.2.6 13,395 3/9/2024
7.2.5 289 2/22/2024
7.2.4 31,974 12/2/2023
7.2.3 6,522 11/3/2023
7.2.2 10,094 10/16/2023
7.2.1 289,168 7/11/2023
7.2.0 2,945 7/7/2023
7.1.2 92,610 4/19/2023
7.1.1 11,369 3/23/2023
7.1.0 19,167 2/1/2023
7.0.0 18,810 11/8/2022
7.0.0-rc2 700 10/19/2022
4.0.0-preview2 3,295 8/4/2022
4.0.0-preview1 3,151 2/10/2022
3.8.0 44,760 5/6/2025
3.8.0-preview5 286 5/12/2025
3.8.0-preview3 243 4/8/2025
3.8.0-preview2 197 4/4/2025
3.8.0-preview1 255 3/31/2025
3.7.2 154,046 5/10/2024
3.7.1 105,178 5/27/2023
3.7.0 23,066 3/23/2023
3.6.5 670,921 8/15/2022
3.6.4 13,594 8/10/2022
3.6.3 17,480 8/4/2022
3.6.2 155,728 4/15/2022
3.6.1 271,078 4/5/2022
3.6.0 327,545 1/20/2022
3.5.1 141,345 11/8/2021
3.5.0 194,433 9/3/2021
3.4.4 1,430 10/4/2021
3.4.3 74,937 6/3/2021
3.4.2 81,245 4/5/2021
3.4.1 148,409 2/3/2021
3.4.0 23,631 1/6/2021
3.4.0-rc1 575 12/9/2020
3.3.0 119,826 9/9/2020
3.3.0-rc2 801 9/2/2020
3.3.0-rc1 661 8/19/2020
3.2.2 106,856 7/22/2020
3.2.1 25,337 7/2/2020
3.2.0 26,026 6/4/2020
3.2.0-rc2 693 5/20/2020
3.2.0-rc1 700 5/7/2020
3.1.7 11,786 5/19/2020
3.1.6 51,536 4/16/2020
3.1.5 3,136 4/9/2020
3.1.4 9,543 3/26/2020
3.1.3 8,399 3/16/2020
3.1.2 15,146 3/5/2020
3.1.0 11,541 2/23/2020
3.1.0-rc3 749 2/13/2020
3.1.0-rc2 722 2/12/2020
3.1.0-rc1 765 2/10/2020
3.0.2 42,145 12/12/2019
3.0.1 17,948 11/27/2019
3.0.0 46,542 10/24/2019
3.0.0-rc2 931 10/16/2019
3.0.0-rc1 702 10/9/2019
3.0.0-beta1 46,349 8/16/2019
2.4.5 187,223 12/29/2019
2.4.4 50,515 11/27/2019
2.4.3 58,530 10/10/2019
2.4.2 38,254 8/31/2019
2.4.1 21,908 8/14/2019
2.4.0 3,373 8/8/2019
2.3.6 14,463 7/24/2019
2.3.5 41,563 6/14/2019
2.3.4 18,805 6/4/2019
2.3.3 3,347 6/2/2019
2.3.2 17,670 5/9/2019
2.3.1 13,736 4/26/2019
2.3.0 59,692 3/20/2019
2.3.0-rc2 3,779 3/13/2019
2.3.0-rc1 2,694 3/4/2019
2.2.4 6,125 2/25/2019
2.2.3 10,561 1/17/2019
2.2.0 28,627 12/13/2018
2.2.0-rc1 2,814 12/4/2018
2.2.0-beta1 3,432 10/21/2018
2.1.2 14,302 10/11/2018
2.1.0 8,285 9/28/2018
2.1.0-rc2 3,330 9/21/2018
2.1.0-rc1 3,434 9/14/2018
2.1.0-beta1 3,488 8/27/2018
2.0.0 24,878 3/28/2018
2.0.0-rc2 3,859 3/13/2018
2.0.0-rc1 3,688 2/26/2018
2.0.0-beta3 4,477 12/21/2017