I fixed this error by specifying –project and –startup-project options to Entity Framework Core CLI tools like this:
dotnet ef database update --verbose --project CommandService.Data --startup-project CommandService
–project means which project contains the DbContext class
–startup-project means which project contains the database connection information and other information.