The definition of specific heat at constant volume is $C_v=\left.\frac {\delta Q} {dT}\right|_v$ but sometimes I find this expression instead: $C_v=\left.\frac {\partial E} {\partial T}\right|_v$ . I guess that the reason why these two expression are both used is that they are equivalent, however I don't know how to demonstrate it.
I tried to demonstrate the equivalence by myself but I was able to do it only assuming $\delta W=-PdV$ indeed in this case: $dE=\delta Q +\delta W=\delta Q - PdV \rightarrow \left.dE\right|_v=\delta Q$ so it follow $C_v=\left.\frac {\delta Q} {dT}\right|_v=\left.\frac {\partial E} {\partial T}\right|_v$ .
However, when I don't assume $\delta W=-PdV$ it becomes impossible for me to show that $C_v=\left.\frac {\delta Q} {dT}\right|_v=\left.\frac {\partial E} {\partial T}\right|_v$. Consider for example the case of a paramagnetic materials, since it can be magnetized the expression for the work should be $\delta W=-PdV+BdM$ where $M$ is the magnetization and $B$ is the magnetic field. Even in this case i think the expression $C_v=\left.\frac {\partial E} {\partial T}\right|_v$ is valid. Why?
Note: in the last example I think that the independent variables are $V$ and $T$ while the number of particle and the magnetic field are taken constant and that $M=M(V,T)$