Anime where a boy is transported to a world with a different sun and enrolls in a magic school?
The show you are looking for is probably Trinity Seven.



Kasuga Arata lived a normal life together with his childhood friend, Hijiri Kasuga, in a small town. However, everything changed on the day of the Black Sun, and a magus (mage) appeared before him. The Black Sun caused the Breakdown Phenomenon which destroyed the town where he lives. Because of this, his normal life was artificially reconstructed by a grimoire that his childhood friend had left. The appearance of the magus led him to a new life in the Royal Biblia Academy and meeting the members of the Trinity Seven.