Database does not have a valid owner

I started to do some work with a SQL Express database that I received from another person. The problems started when I tried to add a Database Diagram to the project. Normally when you do this you do need to create the diagram objects in the database, but this time I received an error message saying that the database did not have a valid owner.

Here is a copy of the error message that I received.

“Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects. “

To fix the problem I first needed to attach the database to the management studio, this can be done in either the full product or the SQL Express Management Studio. Then by going to the properties for the database with the problem and selecting the files tab, change the owner to the [sa] account and select apply. Or you could use the following script.