“Cannot execute as the database principal because the principal “dbo” does not exist, this type of principal cannot be impersonated, or you do not have permission.”
For various reasons, the owner of a database may be deleted or empty. Such an error message may be encountered when there is no owner of a database.
You can skip this error if you have a valid owner of the database.
You can use the following command to change the owner of a database:
EXEC sp_changedbowner 'sa'
ALTER AUTHORIZATION ON DATABASE::MyDatabase TO sa;