There is a circular dependency in the target dependency graph involving target "DockerBuildServiceReferences"

For others who get this error and @VMAtm answer doesn't resolve. It can also happen if you are running the migrations commands in your solution folder, a level above your .csproj and dockerfile. Make sure you are in the project folder when you run migrations.


According this thread and this answer, such situation may occur if you have Dockerfile and the project file (.csproj) not in the same folder, or you have a solution file (.sln) and project file (.csproj) in the same folder.

You've probably created a solution and startup project for it in the same directory, which will lead to docker circular reference. Try to re-create your project with separate folder and redo all the steps.