Entities migration

Most interesting is the tests... which shows how to use these things.

Let me know what you think.... This is a big patch I don't expect a deep review or anything...