In II Samuel 7, God makes to David what appears to be an unconditional promise: God would grant David an everlasting dynasty, in that there would always be a Davidid sitting on the throne of Israel. If the Davidic monarch sins, then God would discipline him, but God wouldn't remove his love from him as he did from King Saul, who lost the throne to David.
In I Kings 8:25, the unconditional promise of an enduring dynasty is made conditional on the Davidic kings' obedience to God's ways.
According to Mordechai Cogan, the conditionality is the work of Dtr2, the second Deuteronomist, who wrote after the Babylonian destruction of Jerusalem and the Davidic dynasty. That shattered belief in its perpetuity.
But is II Samuel 7 really unconditional in its promise of an everlasting dynasty? P. Kyle McCarter points out that I Samuel 2:30 refers to God's intention for the house of Eli to be a priesthood forever, but it came to an end because of its disobedience. So God can change his mind.
And David at the end of II Samuel 7 prays for God to carry out his promise of an everlasting dynasty. Why would David do that, if the promise was a sure thing?
Personally, I think that II Samuel 7 presents an unconditional promise, one that cannot be thwarted by human sin. It says, after all, that God will discipline the king who sins without removing him from the throne. As far as David's prayer is concerned, I've read that biblical characters often ask God to keep his promises, but I'll have to search for examples.
So is it the case that the unconditional promise was pre-exilic, while the promise was made conditional during the exile, after the destruction of the Davidic dynasty? I don't know. In a sense, people in exile could believe in an unconditional promise of a Davidic dynasty. Jeremiah 33:17 states that, after Judah's restoration, David will never lack a man to sit on the throne of Israel. Jeremiah may have believed that God's unconditional promise could be temporarily interrupted through the exile, but it was still unconditional.
Moreover, since we are discussing the Deuteromistic History (Joshua-II Kings), it's important to point out that II Kings ends on a positive note about the Judean monarchy: in II Kings 25:27-30, the king of Babylon lifts up the head of Jehoiachin, the exiled king of Judah. Is there hope that the Davidic dynasty has not been destroyed and has a future, meaning the promise is still unconditional?
And yet, I Kings 8:25 adds conditions to the promise.