Here is a solution without using the PDE technique, which is preferred as we do not need to assume the affine form of a zero-coupon price from the start.
we assume that, under the risk-neutral measure,
\begin{align*}
dr_t = (\theta(t)-a r_t) dt + \sigma dW_t,
\end{align*}
where $a$ and $\sigma$ are constants, $a(t)$ is a deterministic function, and $W_t$ is a standard Brownian motion. We seek to compute the zero-coupon bond price defined by
\begin{align*}
P(t, T) &= E\left(e^{-\int_t^T r_s ds} \mid \mathcal{F}_t \right),
\end{align*}
where $\mathcal{F}_t$ is the information set up to time $t$.
Note that
\begin{align*}
d\left(e^{at} r_t\right) &= be^{at}r_t dt + e^{at} dr_t\\
&=\theta(t)e^{at} dt + \sigma e^{at} dW_t.
\end{align*}
Then, for $s \geq t \geq 0$,
\begin{align*}
e^{as} r_s = e^{at} r_t + \int_t^s \theta(u)e^{au} du + \int_t^s \sigma e^{au} dW_u.
\end{align*}
That is,
\begin{align*}
r_s = e^{-a(s-t)} r_t + \int_t^s \theta(u)e^{-a(s-u)} du + \int_t^s \sigma e^{-a(s-u)} dW_u.
\end{align*}
We then have the integral
\begin{align*}
&\ \int_t^T r_s ds \\
=&\ r_t \int_t^T e^{-a(s-t)} ds + \int_t^T\!\!\!\!\int_t^s \theta(u)e^{-a(s-u)} du ds + \int_t^T\!\!\!\!\int_t^s\sigma e^{-a(s-u)} dW_u ds\\
=&\ \frac{1}{a}\Big(1-e^{-a(T-t)} \Big) r_t + \int_t^T\!\!\!\!\int_u^T \theta(u)e^{-a(s-u)} ds du + \int_t^T\!\!\!\!\int_u^T \sigma e^{-a(s-u)} ds dW_u\\
=&\ \frac{1}{a}\Big(1-e^{-a(T-t)} \Big) r_t + \int_t^T\!\! \frac{\theta(u)}{a}\Big(1-e^{-a(T-u)} \Big)du + \int_t^T \!\!\frac{\sigma}{a}\Big(1-e^{-a(T-u)} \Big)dW_u.
\end{align*}
Let
\begin{align*}
B(t, T) = \frac{1}{a}\Big(1-e^{-a(T-t)} \Big).
\end{align*}
Then,
\begin{align*}
\int_t^T r_s ds &= B(t, T) r_t + \int_t^T \theta(u) B(u, T) du + \int_t^T \sigma B(u, T) dW_u.
\end{align*}
Moreover, the zero-coupon bond price is then given by
\begin{align*}
P(t, T) &= E\left(e^{-\int_t^T r_s ds} \mid \mathcal{F}_t \right)\\
&=\exp\left(-B(t, T) r_t - \int_t^T \theta(u) B(u, T) du + \frac{1}{2}\int_t^T \sigma^2 B(u, T)^2 du\right).
\end{align*}
Note that
\begin{align*}
\int_t^T \sigma^2 B(u, T)^2 du &= \frac{\sigma^2}{a^2}\int_t^T \left(1 - 2e^{-a(T-u)} + e^{-2a(T-u)}\right) du\\
&=\frac{\sigma^2}{a^2}\left(T-t-\frac{2}{a}\Big(1-e^{-a(T-t)}\Big) +\frac{1}{2a} \Big(1-e^{-2a(T-t)}\Big) \right)\\
&= \frac{\sigma^2}{a^2}\left(T-t -\frac{1}{2a}\Big(1-e^{-a(T-t)}\Big)^2-\frac{1}{a}\Big(1-e^{-a(T-t)}\Big)\right)\\
&= -\frac{\sigma^2}{a^2}\big(B(t, T) -T+t\big)-\frac{\sigma^2}{2a}B(t, T)^2.
\end{align*}
Then
\begin{align*}
P(t, T) &= A(t, T) e^{-B(t, T) r_t},
\end{align*}
where
\begin{align*}
A(t, T) &= \exp\left(- \int_t^T \theta(u) B(u, T) du -\frac{\sigma^2}{2a^2}\big(B(t, T) -T+t\big)-\frac{\sigma^2}{4a}B(t, T)^2\right).
\end{align*}
See http://www.math.nyu.edu/~benartzi/Slides10.3.pdf for another derivation using the PDE approach.