dotnet / dotnet/eShop

Initial database migration not working using `OrderingContext`

Open
#543 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.9k
Forks
3.8k
Avg merge
1d 11h
Merged PRs (30d)
4

Description

The instruction in OrderingContext.cs says to run
`dotnet ef migrations add --startup-project Ordering.API --context OrderingContext [migration-name]`.

However, no migrations are added. I have modified the above command to startup on Ordering.Infrastructure (which I think is what you guys meant), but still no luck. I'm trying to do this from a dotnet maui project that uses aspire to orchestrate apis, worker processes and db. Everything is great, except that I cannot get EF to create the initial tables.

when I run ` dotnet ef migrations add MyNewMigration --project Ordering.Infrastructure\Ordering.Infrastructure.csproj --context Ordering.Infrastructure.OrderingContext`

I get the following error -
`dotnet : The specified deps.json [C:\app\bin\Debug\net8.0-android\app.deps.json] does not exist`

NOTE:
1. The db gets created, but the tables dont (because of missing migrations)
2. When I copy over the existing Migrations from the eShop sln to mine, the tables get created. However, it would suck having to manually update the migrations to meet my needs
3. The real question is - How did you create the initial migrations in Ordering.Infrastructure. This is what I really need as my code is 100% identical to eShop

Can you please advise?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.