Magna Entertainment Corp., the country's largest racetrack operator, filed for Chapter 11 bankruptcy in a Delaware court on Thursday and has reached an agreement to sell the majority of its racing assets, including Gulfstream Park and Golden Gate Fields, to its parent company and largest creditor, MI Developments.