@Giorgio this is interesting and it would solve any doubts except i don't see how work exchange is zero if $dV=0$. Take for example the case $M=M(T,V)$, then $\delta W= BdM=B \frac {\partial M} {\partial T}|_v dT$
@GiorgioP I don't think i0m understanding your point, $C_v=\frac {\delta Q} {dT}|_v$ should be the formal definition of $C_v$. I'm trying to show that this is equivalent to $\frac {\partial E} {\partial T}|_v$. If the equivalence is true then when i change the variables both $\delta Q$ and $dE$ should change. Have you seen the edit to the question?
@GiorgioP thank you for the observation. I tried to edit the question to make it clear. About the $\delta W=-PdV+BdM$: i think the magnetic field is taken constant and also the number of particles while $M=M(V,T)$