[WebToolsE2E][Aspire] Running DatabaseMigrations and then clicking the endpoint of the api project gets an error: Cannot open database 'db1' requested by the login.
REGRESSION INFO: Also repro on main branch (Aspire 8.0 P7)
INSTALL STEPS
- Clean machine: Win11 x64 23h2 ENU
- Install VS 17.10 GA FB [ Includes Aspire 8.0.0 and SDK 8.0.300 ]
- Apply NuGet darc-pub-dotnet-aspire Feed
- Install Docker Desktop for Windows
REPRO STEPS
- Clone aspire-samples repo, checkout the
release/8.0branch - Open samples\DatabaseMigrations.sln
- Build and F5
- Click on endpoint of api project
ACTUAL
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open database "db1" requested by the login. The login failed.
Login failed for user 'sa'.
NOTE
- After a while, the migration status will change from running to finished, and you will get an error only when you click on the endpoint of the api project.
EXPECTED
It's expected that this error will occur during application startup while the migration service is attempting to connect to the database and apply migrations. On my machine it takes approximately 25 seconds from the time the migration service starts until it completes running the migrations and after that the api endpoint returns successfully.