This for people who are in the same case as the OP, living very close to a country with a better tax treatment, it is very tempting to rent a house to claim tax residency but without actually spending the required time. To this I have to warn that the tax authorities of the countries have become more and more sophisticated and can analyze things like electricity consumption or credit card payments and if you have not spent the minimum time you are going to have a problem.
It's not that easy to be honest. Many countries in the EU will treat you like subject to their local tax laws unless you prove to them that you're no longer their tax resident and a tax resident is different from a normal resident. You can live somewhere but that doesn't change your residency. To change residency you have to first have registration of residence, or "Anmeldung" is how they call it in Germany. That just proves that you live there and you can start counting your residency from that point. Then you can apply for permanent residence, but residence does not mean tax residence because remember that you're still a citizen of one country, but a resident of another, so you're still on the list of taxpayers in the country from which you've migrated. You have to tell them that you no longer live there and they will most likely check everything thoroughly, because they don't want you to cheat. Remember that you're a money making machine for them. By law most countries will not change your tax residency if you don't live abroad for more than 6 months a year. I also heard that they will deny your request if your wife and children did not move out with you.