desenvolvedor-io / dev-store

A microservices e-commerce reference application built with ASP.NET 6
https://devstore.academy
MIT License
1.05k stars 196 forks source link

[BUG] Cannot use Add-Migrations #32

Open caiovitor opened 1 year ago

caiovitor commented 1 year ago

Describe the bug When I try to use Add-Migration DbInit -context OrdersContext in project DevStore.Orders.Infra I got this error bellow: image

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Package Manage Console'
  2. Select the project 'DevStore.Orders.Infra'
  3. Run the command 'Add-Migration DbInit -context OrdersContext'
  4. See error

Expected behavior Generate migrations files

Screenshots image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

TiagoCastilhos commented 3 months ago

You need to specify your startup project, which would be the api project.

Try opening a CMD in "src/services" directory and exeute the following command:

dotnet ef migrations add "DbInit" -s .\DevStore.Orders.AP\DevStore.Orders.API.csproj -p .\DevStore.Orders.Infra\DevStore.Orders.Infra.csproj --context OrdersContext

NOTE: This command can run at any directory of your application, you just have to set the proper path