aspire-samples icon indicating copy to clipboard operation
aspire-samples copied to clipboard

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

Open v-sherryfan opened this issue 1 year ago • 1 comments

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

  • 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

image

v-sherryfan avatar May 17 '24 04:05 v-sherryfan

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.

DamianEdwards avatar May 17 '24 16:05 DamianEdwards