ARTICLE AD BOX
I am trying to install and configure the HangFire to make background service in an ASP.NET Core 8 MVC app. I have been installing all packages but when I try to make the configurations it throwns an exception about the UseMySqlStorage.
How could I fix it ?
Error (active) CS1061
'IGlobalConfiguration' does not contain a definition for 'UseMySqlStorage' and no accessible extension method 'UseMySqlStorage' accepting a first argument of type 'IGlobalConfiguration' could be found (are you missing a using directive or an assembly reference?)
FederalzinhaProject C:\Users\fernando\AspNetCoreProjects\federalzinharepository\FederalzinhaProject\Extensions\ServiceCollectionExtensions.cs 119
Usings:
using Hangfire; using Hangfire.Dashboard; using Hangfire.MySql;HangFire packages used:
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.22" /> <PackageReference Include="Hangfire.Core" Version="1.8.22" /> <PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />And in ServiceCollectionExtensions, I added:
// MySQL Connection (works) var connnectionString = configuration.GetConnectionString("DefaultConnection"); services.AddDbContext<ApplicationDbContext>(options => options.UseMySql( connnectionString, new MySqlServerVersion(new Version(8, 0, 39)) )); // HANGFIRE (not works) services.AddHangfire(configuration => configuration .UseMySqlStorage(connnectionString, new MySqlStorageOptions { }) ); services.AddHangfireServer();All packages in the project:
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <Nullable>disable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> <ItemGroup> <!-- EF Core 9.0 Preview (compatível com Pomelo preview) --> <PackageReference Include="AspNetCore.HealthChecks.UI" Version="9.0.0" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" /> <PackageReference Include="BCrypt.Net-Next" Version="4.0.3" /> <PackageReference Include="Hangfire.AspNetCore" Version="1.8.22" /> <PackageReference Include="Hangfire.Core" Version="1.8.22" /> <PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" /> <PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.477" /> <PackageReference Include="MailKit" Version="4.14.1" /> <PackageReference Include="mercadopago-sdk" Version="2.10.0" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.1.24081.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0-preview.1.24081.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.1.24081.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.1.24081.2"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="10.0.0" /> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" /> <!-- Pomelo MySQL (preview compatível) --> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.1" /> <!-- SIGNAL HUB --> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" /> </ItemGroup> <ItemGroup> <None Include="wwwroot\Imagens\ajaxloader.gif" /> <None Include="wwwroot\lib\bootstrap\css\bootstrap.min.css" /> <None Include="wwwroot\lib\bootstrap\js\bootstrap.bundle.min.js" /> <None Include="wwwroot\lib\datatables-bs5\dataTables.bootstrap5.min.css" /> <None Include="wwwroot\lib\datatables-bs5\dataTables.bootstrap5.min.js" /> <None Include="wwwroot\lib\datatables\dataTables.min.js" /> <None Include="wwwroot\lib\fontawesome\css\all.min.css" /> <None Include="wwwroot\lib\jquery-mask\jquery.mask.min.js" /> <None Include="wwwroot\lib\jquery\jquery.min.js" /> </ItemGroup> </Project>