✅ DbContextOptionsBuilder.UseMongoDB is not referenced after use AspNetCore.HealthChecks.MongoDb

As above I recently added AspNetCore.HealthChecks.MongoDb to my project and the code below stop working
builder.Services.AddDbContext<LightningLanesDbContext>((serviceProvider, opt) =>
{
var databaseSettings = serviceProvider.GetRequiredService<IOptionsMonitor<DatabaseSettings>>().CurrentValue;
//This line
opt.UseMongoDB(databaseSettings.ConnectionString, databaseSettings.Name);
});
builder.Services.AddDbContext<LightningLanesDbContext>((serviceProvider, opt) =>
{
var databaseSettings = serviceProvider.GetRequiredService<IOptionsMonitor<DatabaseSettings>>().CurrentValue;
//This line
opt.UseMongoDB(databaseSettings.ConnectionString, databaseSettings.Name);
});
What i'm currently using (Without the package AspNetCore.HealthChecks.MongoDb)
<PackageReference Include="MongoDB.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="MongoDB.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
Error
C:\Users\Strypper\source\repos\TotechsThunder\src\LightningLanes\API\Program.cs(50,5): error CS0012: The type 'IMongoClient' is defined in an assembly that is not referenced. You must add a reference to assembly 'MongoDB.Driver, Version=2.25.0.0, Culture=neutral, PublicKeyToken=null'.

Build failed with 1 error(s) and 16 warning(s) in 4,0s
C:\Users\Strypper\source\repos\TotechsThunder\src\LightningLanes\API\Program.cs(50,5): error CS0012: The type 'IMongoClient' is defined in an assembly that is not referenced. You must add a reference to assembly 'MongoDB.Driver, Version=2.25.0.0, Culture=neutral, PublicKeyToken=null'.

Build failed with 1 error(s) and 16 warning(s) in 4,0s
3 Replies
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
TotechsStrypper
TotechsStrypperOP3mo ago
Thanks you for bring the MongoDB.EntityFrameworkCore and the Microsoft.EntityFrameworkCore to my attention I update them to the latest version and 3 of them work perfectly
MODiX
MODiX3mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server