# StorageProviderExtensions Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.hosting.storageproviderextensions/)

## AddGrainStorage(IServiceCollection, string, Func&lt;IServiceProvider, string, T&gt;) {#addgrainstorage-1-this-microsoft-extensions-dependencyinjection-iservicecollecti-e2b00898}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.hosting.storageproviderextensions/methods/addgrainstorage-1-this-microsoft-extensions-dependencyinjection-iservicecollecti-e2b00898/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Runtime/Hosting/StorageProviderHostExtensions.cs#L24-L38)

```csharp
public static IServiceCollection AddGrainStorage<T>(this IServiceCollection collection, string name, Func<IServiceProvider, string, T> implementationFactory)
```

Add a grain storage provider implementation to the silo. If the provider type implements `Orleans.ILifecycleParticipant-1` it will automatically participate to the silo lifecycle.

### Parameters

- `collection` (`IServiceCollection`): The service collection.
- `name` (`string`): The name of the storage to add.
- `implementationFactory` (`Func<IServiceProvider, string, T>`): Factory to build the storage provider.

### Returns

The service provider.
