I have added my dbContext in separate class library and added referce of this project to WebAPI project.
Now i want to create a migrations. But to create it i need to add some entity framework references into webapi project too.
this will violate SOP principle of my architechture.
So how can i implement code first approch where my web api is not dependent on DB layer?
>Solution :
It is not necessary for your webapi project to have a direct dependency on EntityFramework.
You can specify your database class library project to be the one which will hold the migrations. E.g:
dotnet ef migrations add MigrationName --project DatabaseClassLibrary --startup-project WebApiProject
The above command will use the WebApiProject as the startup-project as that will most likely (but not always) have the DI setup for creating an instance of your DbContext for your database provider.