Let $R\to S$ be a ring map such that $S$ is projective over $R$ (I am willing to assume $S=R[X_1,...,X_n]$). Let $M,N$ be finite $S$-modules. Let $P\in Spec R$ such that $M_P$ is $R_P$-flat. Under what condition can one say that $Ext^1_R(M,N)_P=0$?

This is trivial if $M$ is finite over $R$, but in general $Ext$ does not commute with localization. I would appreciate any reference on this matter.