There is a broad consensus that
the prayer(s) of Solomon in 1 Kings 8 depends on the Promise from 2 Samuel 7.
This is especially true of the second (vv. 14-21) and third (vv. 22-61)
prayers. The first prayer is independent, but there are some points that may
associate the first prayer with 2 Samuel 7. It bears no indication of
Deuteronomic influence, and Weinfeld describes it as an "ancient
song" which was "apparently recited by Solomon during the temple
inauguration ceremonies. First Kings 8:12-13 reads,
אז אמר שלמה יהוה אמר לשׁכן בערפל בנה
בניתי בית זבל לך מכון לשבתך עולמים
Then Solomon said, "YHWH has
said that he would dwell in thick darkness. I have built you a house of
habitation, a place for you to dwell in forever."
The language here alludes to 2 Samuel 7.
According to this source, YHWH will dwell (לשׁבתך) in the temple which Solomon
is building. Likewise, David wants to build a place for YHWH to dwell (2 Sam
7:5, לשׁבתי), and although YHWH rejects David's offer to build a temple it is
still clear that YHWH himself dwells in earthly edifices like the tent and
tabernacle (vv. 6-7). The relationship between 1 Kings 8:12-13 and 2 Samuel
7:1-17 is only thematic; both assume YHWH’s physical dwelling place is in the
temple. (William M. Schniedewind, Society and the Promise to David:
The Reception History of 2 Samuel 7:1-17 [Oxford: Oxford University Press,
1999], 43-44)