# How to fix UsePostgreSqlStorage is obsolete: 'Will be removed in 2.0. in Hangfire string connection?

**URL:** <https://discuss.hangfire.io/t/how-to-fix-usepostgresqlstorage-is-obsolete-will-be-removed-in-2-0-in-hangfire-string-connection/10716>\
**Category:** question\
**Tags:** postgres\
**Created:** [May 22, 2024, 4:52pm UTC](https://discuss.hangfire.io/t/how-to-fix-usepostgresqlstorage-is-obsolete-will-be-removed-in-2-0-in-hangfire-string-connection/10716 "2024-05-22T16:52:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![solosurge](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@solosurge](https://discuss.hangfire.io/u/solosurge)\
**Post date:** [May 22, 2024, 4:52pm UTC](https://discuss.hangfire.io/t/how-to-fix-usepostgresqlstorage-is-obsolete-will-be-removed-in-2-0-in-hangfire-string-connection/10716/1 "2024-05-22T16:52:43Z")

</div>

**The following code snippet is currently generating a warning:**

```auto
builder.Services.AddHangfire(config => config
    .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
    .UseSimpleAssemblyNameTypeSerializer()
    .UseRecommendedSerializerSettings()
    .UsePostgreSqlStorage(defaultConnString));

```

**The warning message is as follows:**

‘PostgreSqlBootstrapperConfigurationExtensions.UsePostgreSqlStorage(IGlobalConfiguration, string)’ is marked as obsolete: ‘This method will be removed in version 2.0. Please use the UsePostgreSqlStorage(Action) overload instead.’

**The versions of the packages currently in use are:**

```auto
<TargetFramework>net7.0</TargetFramework>
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.12" />
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.8" />

```

**Despite the warning, this is the only configuration that works for me. Any assistance would be greatly appreciated.**

---

<div class="post-metadata">

**Author:** ![leashjay](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/leashjay/32/3708_2.png) [@leashjay](https://discuss.hangfire.io/u/leashjay)\
**Post date:** [May 22, 2024, 10:31pm UTC](https://discuss.hangfire.io/t/how-to-fix-usepostgresqlstorage-is-obsolete-will-be-removed-in-2-0-in-hangfire-string-connection/10716/2 "2024-05-22T22:31:54Z")

</div>

This isn’t quite an answer but have you looked around the connections factories in their code

```csharp
[Obsolete("Will be removed in 2.0, please use the overload with IConnectionFactory argument")]
public PostgreSqlStorage(string connectionString) : this(connectionString, new PostgreSqlStorageOptions()) { }

```

[`NpgsqlConnectionFactory`](https://github.com/hangfire-postgres/Hangfire.PostgreSql/blob/28da820163fc6736fa78d43e7ff16dbfb3518440/src/Hangfire.PostgreSql/Factories/NpgsqlConnectionFactory.cs#L10)

---

<div class="post-metadata">

**Author:** ![solosurge](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@solosurge](https://discuss.hangfire.io/u/solosurge)\
**Post date:** [May 23, 2024, 1:35am UTC](https://discuss.hangfire.io/t/how-to-fix-usepostgresqlstorage-is-obsolete-will-be-removed-in-2-0-in-hangfire-string-connection/10716/3 "2024-05-23T01:35:39Z")

</div>

I’ve tried to set up Hangfire with the corrected configuration. Still gives me an error:

```auto
builder.Services.AddHangfire(config => config
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180) .UseSimpleAssemblyNameTypeSerializer() 
.UseRecommendedSerializerSettings() 
.UsePostgreSqlStorage(options => 
{ 
    options.ConnectionString = connString; 
}));

```

error:

‘PostgreSqlBootstrapperOptions’ does not contain a definition for ‘ConnectionString’ and no accessible extension method ‘ConnectionString’ accepting a first argument of type ‘PostgreSqlBootstrapperOptions’ could be found (are you missing a using directive or an assembly reference?)

---

<div class="post-metadata">

**Author:** ![solosurge](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@solosurge](https://discuss.hangfire.io/u/solosurge)\
**Post date:** [May 24, 2024, 3:36pm UTC](https://discuss.hangfire.io/t/how-to-fix-usepostgresqlstorage-is-obsolete-will-be-removed-in-2-0-in-hangfire-string-connection/10716/4 "2024-05-24T15:36:00Z")

</div>

I got it working without a warning.

It appears that the UseNpgsqlConnection method is a valid method within the PostgreSqlStorageOptions class in my version of Hangfire. This method is likely a convenience method provided by the Hangfire.PostgreSql extension to simplify the configuration of the PostgreSQL storage.

```auto
builder.Services.AddHangfire(config => config
    .SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
    .UseSimpleAssemblyNameTypeSerializer()
    .UseRecommendedSerializerSettings()
    .UsePostgreSqlStorage(options => options.UseNpgsqlConnection(connString)));

```
