Reputation: 635
I have recently started ASP.net core project with multilayered architecture, where CatalogDbContext and StartUp class in different layers:
I want to add migrations to DroneStore.Data layer. I change in command prompt current directory to ../DroneStore.Data/ and add command:
dotnet ef migrations add Initial
And got an error:
Unable to create an object of type 'CatalogDbContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
When I change current directory to ../DroneStore.Web/ and add this command i got error:
Your target project 'DroneStore.Web' doesn't match your migrations assembly 'DroneStore.Data'. Either change your target project or change your migrations assembly
Any suggections?
Upvotes: 4
Views: 2566
Reputation: 635
1) Change your currend directory in command prompt to:
cd ../DroneStore.Data/
2) Add to command -s option with path to StartUp project folder:
dotnet ef migrations add Initial -s ../DroneStore.Web/
Upvotes: 8