dotnet / aspire-samples

MIT License
647 stars 186 forks source link

[WebToolsE2E][Aspire] Running DatabaseMigrations and then clicking the endpoint of the api project gets an error: Cannot open database 'db1' requested by the login. #279

Closed v-sherryfan closed 2 months ago

v-sherryfan commented 4 months ago

REGRESSION INFO: Also repro on main branch (Aspire 8.0 P7)

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install VS 17.10 GA FB [ Includes Aspire 8.0.0 and SDK 8.0.300 ]
  3. Apply NuGet darc-pub-dotnet-aspire Feed
  4. Install Docker Desktop for Windows

REPRO STEPS

  1. Clone aspire-samples repo, checkout the release/8.0 branch
  2. Open samples\DatabaseMigrations.sln
  3. Build and F5
  4. Click on endpoint of api project

ACTUAL

image 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'. image

NOTE

EXPECTED

image

DamianEdwards commented 4 months ago

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.