Skip to content

Mongo Migration dependency before Background service kicks off - .NET Core #80

@rajurh

Description

@rajurh

Hello, I am working on a .NET 6 project that includes a background service. I have configured the migration in the startup as shown below. However, I have a problem: the background service tries to access the database before it is ready. This happens when the migration takes longer than usual to set up MongoDB. How can I ensure that the background service waits for the migration to finish before performing any database operations?

services
.AddMigration(new MongoMigrationSettings
{
Database = "blabla",
ConnectionString = config.GetConnectionString("MongoDb"),
DatabaseMigrationVersion = new DocumentVersion(1, 0, 0)
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions