# It seems that the Euler equation in thermodynamics and The first law of thermodynamics are in contradiction

The Euler equation in thermodynamics are as followed:
$$U=TS-PV+\mu N$$
But The first law of thermodynamics states that
$$dU=TdS-PdV+\mu dN$$
But I think that The Euler equation can be written by
$$dU=TdS+SdT-PdV-VdP+\mu dN+Nd\mu$$
Then, $$SdT-VdP+Nd\mu=0$$
But I don't think that this is always correct.
Edit
I see that it's only correct if the system's homogeneous. Can you give me an example of a homogeneous system and nonhomogeneous system?

The Euler equation is a consequence of the extensive property of energy $$U(\lambda S,\lambda V,\lambda N)= \lambda U(S,V,N)$$. \begin{align}U(S,V,N)&=\Big(\frac{\partial{U}}{\partial{S}}\Big)_{N,V}S+\Big(\frac{\partial{U}}{\partial{V}}\Big)_{N,S}V+\Big(\frac{\partial{U}}{\partial{N}}\Big)_{S,V}N\\ &=TS-PV+\mu N\end{align}
And the first law of thermodynamics is just a statement which says that energy is conserved. $$U(S,V,N)$$ is a state function and therefore $$dU(S,V,N)$$ is an exact differential, it can be written in the form shown below.
\begin{align}dU(S,V,N)&= \Big(\frac{\partial{U}}{\partial{S}}\Big)_{N,V}dS+\Big(\frac{\partial{U}}{\partial{V}}\Big)_{N,S}dV+\Big(\frac{\partial{U}}{\partial{N}}\Big)_{S,V}dN\\&=TdS-PdV+\mu dN \end{align}
Both the Euler equation and the first law of thermodynamics are logical consequences of different properties of energy, $$U(S,V,N)$$ (extensivity and conservation of energy) and both are true.
As you concluded, this leads to $$SdT-VdP+Nd\mu=0$$, which is the Gibbs-Duhem equation. Your question is the proof of Gibbs-Duhem equation.