Let $R$ be a ring, and let $S$ be an $R$-algebra. Let $M$ be an $R$-module. Under what conditions on $R$, $S,$ and $M$ is it true that we have the following isomorphism of $S$-modules? $$S \otimes_R \operatorname{Hom}_R(M, R) \simeq \operatorname{Hom}_S(S \otimes_R M, S)$$
I know there is an obvious map from the left-hand side above to the right-hand side (namely, send a map $\phi \colon M \to R$ to the map $\operatorname{id} \otimes_R\, \phi$), but I do not know what conditions are required for there to be an inverse map. Does this have anything to do with $M$ being torsion-free as an $R$-module?