C
C#2y ago
M B V R K

✅ Adding EF Core Migration Error

Hi friends, I have a solution contains the structure mentioned in the attached screen-shot, All the projects are Class Library, except the WEB project is an ASP.Net Core 7 Angular APP. The issue: In the EF Core project I have setup the EF Core DBContext, and the WEB project contains the Conenction String in the AppSettings.Json. When I try dotnet ef migration add Initial command I get the following error :
Unable to create an object of type 'AppDbContext'. For the different patterns supported at design time, see ...
Note: I'm using the VS Code IDE, Question: Please how do I can solve this issue ? Massive thanks in advance.
5 Replies
kb7fhe
kb7fhe2y ago
Ensure you have the correct "Default project" selected in the Package Manager Console:
M B V R K
M B V R K2y ago
I'm using Visual Studio Code not Visual Studio Especially this is the first time for me to take this advanture and developing this kind of apps using VS Code
Cisien
Cisien2y ago
You may need to play around with the project and startup ptoject command line switches
M B V R K
M B V R K2y ago
Alright I fixed it by using the following CLI command:
dotnet ef migrations add <migration_name> --startup-project ../WEB --project .
dotnet ef migrations add <migration_name> --startup-project ../WEB --project .
Cisien
Cisien2y ago
Yep