Skip to content

OrleansContrib/Orleans.StorageProviders.SimpleSQLServerStorage

Repository files navigation

Orleans.StorageProviders.SimpleSQLServerStorage

Build status

NuGet

A KeyValue SQLServer implementation of the Orleans Storage Provider model. Uses an EF code-first table to store grain keys with binary and/or json serialized data

Usage

Install-Package Orleans.StorageProviders.SimpleSQLServerStorage

Decorate your grain with the StorageProvider attribute e.g.

[StorageProvider(ProviderName = "PubSubStore")]

in your OrleansConfiguration.xml configure the provider like this:

<StorageProviders>
      <Provider Type="Orleans.StorageProviders.SimpleSQLServerStorage.SimpleSQLServerStorage" Name="PubSubStore"
                ConnectionString="Data Source=(LocalDB)\v11.0; Integrated Security=True;"
                UseJsonFormat="false" />
      
      <Provider Type="Orleans.StorageProviders.SimpleSQLServerStorage.SimpleSQLServerStorage" Name="SomeOtherGrainStorage"
                ConnectionString="Data Source=(LocalDB)\v11.0; Integrated Security=True;"
                UseJsonFormat="both" />
    </StorageProviders>

Setup

If using SQLServer proper, create an empty database and make sure the connecting user has the following permissions

[db_datareader]
[db_datawriter]
[db_ddladmin]

Configuration

The following attributes can be used on the <Provider/> tag to configure the provider:

  • UseJsonFormat="true/false/both" (optional) Defaults to false, if set to false the Orleans binary serializer is used. If set to true json data is serialized. if set to both then both json and binary data is produced and persisted, but the binary data is used for deserialization(meant for debugging purposes).
  • ConnectionString="..." (required) the connection string to your SQLServer database (i.e. any standard SQL Server connection string)