< Previous Challenge — Home — Next Challenge >
The eShopOnWeb solution uses two separate EF Core databases:
| Context | Database | Contents |
|---|---|---|
CatalogContext |
Microsoft.eShopOnWebCatalogDb |
Products, catalog types, catalog brands |
AppIdentityDbContext |
Microsoft.eShopOnWebIdentityDb |
ASP.NET Core Identity users and roles |
In Challenge 03 you provisioned an Azure SQL Database and deployed containers that point at it — but the schema has not been created and no data exists. This challenge completes that work and validates the end-to-end stack.
Use the EF Core CLI to apply migrations for both contexts against your Azure SQL databases provisioned in Challenge 03. Each context (CatalogContext and AppIdentityDbContext) targets a separate database and must be applied independently. Look up the EF Core CLI database update command and the options for targeting a specific connection string without modifying appsettings.json.
The application seeds data on first startup when the database is empty. Trigger seeding by starting the Web Container App (or running locally with Azure SQL as target) and verify:
- The catalog page shows all products with images loading from Blob Storage
- Login works with
demouser@microsoft.com/Pass@word1 - The admin user can access
/adminand the Blazor admin panel loads
Query the Azure SQL Catalog database to verify the seeded row counts match the expected values:
| Table | Expected rows |
|---|---|
CatalogItems |
12 |
CatalogBrands |
4 |
CatalogTypes |
4 |
- Browse catalog → all products display with Blob Storage images
- Add items to basket → basket persists across requests
- Place an order → order appears in the database + Service Bus message is published
- Log in as admin → Blazor admin panel shows order history
To complete this challenge successfully, demonstrate:
- Both EF Core migration commands complete without errors against Azure SQL
- The catalog page shows the seeded products when running fully on Azure
- Login with
demouser@microsoft.com/Pass@word1succeeds - Row counts in Azure SQL match expected seed data
- An end-to-end order flow completes without errors
- Explain to your coach — eShopOnWeb uses two separate
DbContextclasses and two separate databases. What is the architectural benefit of this separation, and what operational overhead does it introduce?
- EF Core migrations — applying to a database
- EF Core — multiple DbContexts
- Azure SQL connection strings
- EF Core 10 — what's new
- Your Challenge 03 Terraform outputs contain the Azure SQL Server FQDNs and database names you need.
- The EF Core CLI accepts a
--connectionflag to target a specific connection string without modifyingappsettings.json— useful for one-off migration runs against Azure. - The two
DbContextmigration histories are tracked independently — run both migration commands separately. - If EF Core reports a migration mismatch after the .NET 10 upgrade, drop and recreate the database from scratch.