Solomon made an alliance with Pharaoh, the king of Egypt, and married one of his daughters. He brought her to live in the City of David until he could finish building his palace and the Temple of the Lord and the wall around the city.
The entire building was completed in every detail by midautumn, in the month of Bul, during the eleventh year of his reign. So it took seven years to build the Temple.