I just downloaded a project with Entity Framework installed; the difference with my co-workers is that I'm using a Mac.
I created a docker container for the database, and someone sent me a backup of the database, so I have the database restored and working with the project.
Someone created a new database migration, so I pulled the changes and needed to run the update database command. So I need to use the CLI version because it does not have the Package Manager Console.
So I try to run: dotnet ef database update 20221229175926_addSalariesTable
But this is returning:
Unable to create an object of type 'MyContext'. For the different patterns supported at design time
My project consists in two layers, one for the web and the other for models and data
Web project name: Web
Data project name: Persistence
How can I run the update migration correctly?
CodePudding user response:
You will need to navigate to the directory that contains your data project (Persistence
) in the command line and execute the following command:
dotnet ef database update 20221229175926_addSalariesTable --project Persistence --startup-project Web
This command tells the Entity Framework to update the database using the migration with the specified name and to look for the migration files in the Persistence
project.