title: Configuring ADO.NET Providers

Configuring ADO.NET Providers

Any reliable deployment of Orleans requires using persistent storage to keep system state, specifically Orleans cluster membership table and reminders. One of the available options is using a SQL database via the ADO.NET providers.

In order to use ADO.NET for persistence, clustering or reminders, one needs to configure the ADO.NET providers as part of the silo configuration, and, in case of clustering, also as part of the client configurations.

The silo configuration code should look like this:

  1. var siloHostBuilder = new SiloHostBuilder();
  2. var invariant = "System.Data.SqlClient"; // for Microsoft SQL Server
  3. var connectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Orleans;Integrated Security=True;Pooling=False;Max Pool Size=200;Asynchronous Processing=True;MultipleActiveResultSets=True";
  4. //use AdoNet for clustering
  5. siloHostBuilder.UseAdoNetClustering(options =>
  6. {
  7. options.Invariant = invariant;
  8. options.ConnectionString = connectionString;
  9. });
  10. //use AdoNet for reminder service
  11. siloHostBuilder.UseAdoNetReminderService(options =>
  12. {
  13. options.Invariant = invariant;
  14. options.ConnectionString = connectionString;
  15. });
  16. //use AdoNet for Persistence
  17. siloHostBuilder.AddAdoNetGrainStorage("GrainStorageForTest", options =>
  18. {
  19. options.Invariant = invariant;
  20. options.ConnectionString = connectionString;
  21. });

The client configuration code should look like this:

  1. var siloHostBuilder = new SiloHostBuilder();
  2. var invariant = "System.Data.SqlClient";
  3. var connectionString = "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Orleans;Integrated Security=True;Pooling=False;Max Pool Size=200;Asynchronous Processing=True;MultipleActiveResultSets=True";
  4. //use AdoNet for clustering
  5. siloHostBuilder.UseAdoNetClustering(options =>
  6. {
  7. options.Invariant = invariant;
  8. options.ConnectionString = connectionString;
  9. });

Where the ConnectionString is set to a valid AdoNet Server connection string.

In order to use ADO.NET providers for persistence, reminders or clustering, there are scripts for creating database artifacts, to which all servers that will be hosting Orleans silos need to have access. Lack of access to the target database is a typical mistake we see developers making.

The scripts will be copied to project directory \OrleansAdoNetContent where each supported ADO.NET extensions has its own directory, after you install or do a nuget restore on the AdoNet extension nugets. We split AdoNet nugets into per feature nugets: Microsoft.Orleans.Clustering.AdoNet for clustering, Microsoft.Orleans.Persistence.AdoNet for persistence and Microsoft.Orleans.Reminders.AdoNet for reminders.