NikiforovAll / aspire-depends-on

Control startup dependencies between Aspire Host Components
https://nikiforovall.github.io/dotnet/aspire/2024/06/28/startup-dependencies-aspire.html
MIT License
8 stars 0 forks source link

SQL Server WithHealthCheck will wait forever if the database itself does not exists #1

Open schuettecarsten opened 1 month ago

schuettecarsten commented 1 month ago

SQL Server WithHealthCheck will wait forever if the database itself does not exists.

Imagine this code:

var db = builder.AddSqlServer("sqlserver")
    .WithDataVolume("sqldata")
    .AddDatabase("sqldb")
    .WithHealthCheck();

var migrator = builder.AddProject<Projects.MigrationService>("migrator")
    .WithReference(db)
    .WaitFor(db);

The MigrationService will run the migrations and create the database if it does not exist. When WaitFor(db) and WithHealthCheck() is used, the migration service will never start. It looks like there is no valid solution for this except trying to connect to the SQL server without specifying the database name?

NikiforovAll commented 1 month ago

You can wait for sqlServer

var server = der.AddSqlServer("sqlserver");
var db= ...

var migrator = builder.AddProject<Projects.MigrationService>("migrator")
    .WithReference(db)
    .WaitFor(server);