It is not about the method of transportation. It’s about where you are coming from and what are your destination country’s restrictions. In some cases, you can argue that you are transiting only, and you should be allowed to do so. I recommend double-checking before departing the information, whether on official governmental websites or information desks at train stations/ airports. I recently had to travel from Germany to France and got all the necessary information at
db auskunft. The good thing about it is that you are sure the information is reliable as you are getting it from the same people that will be checking your documentation.