I found that growing the purple variety of carrot seems resistant to carrot fly. I grew three patches of carrot this past year, and the ordinary common orange carrot was touched by the fly, but the purple type was virtually unscathed.
All this stuff about growing garlic or onions close by has not proved successful here in Northumberland. The best method is, for me, to lay fleece over the seeds and this is the necessary barrier to prevent the fly invading.