✅ How to create migration correctly? What do I do wrong?
Command in Package Manager Console:
PM>
add-migration UpdateSomeModels -contex ReadModelDbContext
Error:
7 Replies
Do you have di setup for this as well?
you might need to add which project has your DB context and which has your startup
The migration builder will actually build your app configuration and service provider
Seems like the config isn't hooked up properly
I have two projects:
A with DI setup
B with dbcontext
I want to create migrations in B that's why I set B as startup project and write this command: add-migration UpdateSomeModels -contex dbcontex
but it doesn't work
you need to do
the context option shouldn't be used unless you have multiple DB contexts
also I recommend to use the newer tool:
dotnet ef migrations add ...`ahh I found the problem!
we should set a class with DI as startup and create migration in project with dbcontext
thanks