As female carrot flies are very low flying, the best method of prevention is to erect a barrier around the crop at least 2 feet (60 cm) high. Alternatively horticultural fleece may be used as a floating mulch to cover the crop. Because the carrot fly is attracted to host plants by odor, masking the smell of the host plant by planting odoriferous companion crops such as onions, chives, and garlic can successfully deter attack.
To prevent female carrot flies from reaching the crop, a physical barrier should be erected around it at least 2 feet (60 cm) high. An additional method is to use horticultural fleece as a floating mulch to cover the crop. By masking the scent of the host plant with odoriferous companion crops like onions and garlic, the carrot fly's attraction can be successfully deterred.