Tensor product $M\otimes_B Hom_B(M,B)$ equals $End_B(M)$, $M$ finitely generated over $B$ and projective Let $k$ be a commutative ring and $B$ an algebra over $k$. Consider a projective and finitely generated right $B$ module $M$. We equip $Hom_B(M,B)$ here with a $B$-module structure given by left action $$B\times Hom_B(M,B) \to Hom_B(M,B) \\ (b,f) \mapsto bf(m)$$ where $B$ is a module over itself, with action of multiplication in $B$. 
Moreover, one gives $B$-module structure to $End_B(M)$ via left action $$B\times End_B(M)\to End_B(M) \\ (b,T) \mapsto m \mapsto T(m)b$$
I want to verify $M\otimes_B Hom_B(M,B) \simeq End_B(M)$.
As I don't have any smart idea, I tried to do it by definition: 
Let $g: M \times  Hom_B(M,B) \to N$ be $B$-bilinear function. Now pose $$\phi: M \times Hom_B(M,B) \to End_B (M) \\ (m,f) \mapsto m' \mapsto m'f(m),$$ which is a $B$-bilinear function.  And I'm stuck here: what I need is a $B$-linear map $\widetilde{\phi}:End_B(M) \to N$ such that $g=\widetilde{\phi}\phi$.
Does anyone have an insight or smarter idea? 
 A: I'm sure it can be found in a more standard source, but I do know that in Michel Broue's paper Higman's Criterion Revisited (Michigan Math. J. 58 (2009)), Theorem 1.7 p. 131, he lays out eight equivalent definitions of what it means for a finitely generated $B$-module $M$ to be projective. The isomorphism you seek is the eighth condition there (in conjunction with the fifth condition). His conventions are a little different so the tensor product is flipped, but the arguments are essentially the same. I'm not sure what definition of projective you're using, but the usual standard four definitions are listed there as (i)-(iv), so you should be able to trace through the equivalences regardless. 
A: There is a natural map $\phi:M\otimes\hom(M,B)\to\hom(M,M)$ such that $\phi(m\otimes f)(m')=mf(m')$. As you note, this is an isomorphism if $M$ is finitely generated and projective, and usually not an isomorphism if not. It follows that if we want to exhibit an inverse we have to use the hypothesis somehow: the map $\phi$ can be written down for all $M$ but the inverse has to have some problem or another.
Let $(f_i,m_i)_{i\in I}$ be a finite dual basis for $M$, that is, let $I$ be a finite set, $m_i\in M$ and $f_i:M\to B$ for each $i\in I$, and $m=\sum_{i\in I}f_i(m)m_i$ for all $m\in M$. Then we can define a map $\psi:\hom(M,M)\to M\otimes \hom(M,B)$ putting $$\psi(g)=\sum_{i\in I} g(m_i)\otimes f_i$$ for all $g\in\hom(M,M)$. You should have no problem showing that $\phi$ and $\psi$ are mutually inverse.
