The EU treaties prohibit national discrimination. Previously prohibition only applied to employees who were mentioned specifically in the treaties.
The European Court of Justice has expanded the reach of the ban on discrimination, so that persons not currently in the labour market are also now covered.
The ruling in the Casagrande case (case 9/74) thus made discrimination against persons in the educational system illegal. At the time of that case (1974), education was not covered by the treaties.
Member states are obliged to pay social contributions in respect of foreign workers working in their territory without national discrimination.
An example of legal activism and discrimination.