There are three scenarios. These differ based on the time difference between the first patent application (EP1) being filed and the second patent application (EP2) being filed.
EP2 is filed 18 months (or more) after EP1
In this case, EP1 will be published.
There is no difference between your own publication and one by another party. If, in view of EP1, the invention of EP2 lacks novelty or an inventive step over EP1, then EP2 is not patentable.
EP2 is filed 12–18 months after EP1
EP1 has not published yet, so is not prior art (in the classical sense).
However, EPC art 54(3) provides:
Additionally, the content of European patent applications as filed, the dates of filing of which are prior to the date referred to in paragraph 2 and which were published on or after that date, shall be considered as comprised in the state of the art.
Thus, the content of an earlier-filed but later-published application is prior art. It only becomes prior art once it is published (as in the normal way), but this prior art is deemed to be published at its filing date.
However, this kind of prior art is only relevant for novelty. This is made explicit by EPC art 56, which provides:
…If the state of the art also includes documents within the meaning of Article 54, paragraph 3, these documents shall not be considered in deciding whether there has been an inventive step.
Thus, if the invention of EP2 is novel over the contents of EP1 (even if it lacks an inventive step), you will have no problem.
However, if EP1 does deprive EP2 of novelty, there is still a way to keep EP2. This requires abandoning EP1 before it is published. In this case, EP1 will never become art 54(3) prior art (since it must be published to be art 54(3) prior art), and therefore allows EP2 to proceed.
EP2 is filed less than 12 months after EP1
The situation is basically the same as in the 12–18 month scenario. However, if EP2 lacks novelty over EP1, this can be simply overcome by claiming priority to EP1.