With the continuous expansion of music education, the theory about education ecology has a close relationship with the development of music education because of its novel and scientific viewpoints on nature, environment, ecology, etc. Therefore, many scholars regard educational ecological theory as an important research method. Judging from the current development of music teaching, there are many problems in the current music teaching, such as lack of culture, the disconnect between music education and real life, and the imbalance of music teaching methods. Based on this, from the perspective of education ecology, this paper proposed the rational application of dramatic elements to the music teaching model. The teaching quality was evaluated by data mining method to analyze the effectiveness of the method. At the same time, it can promote the promotion of drama culture, which is conducive to strengthening the inheritance of school drama culture and improving the school's sense of responsibility for the inheritance of drama culture. The experimental results showed that after the music teaching integrates the drama element, the music scores of the students were all above 85 points; the average score of the grade with the least improvement in music increased by 4.1 points, and the average score of the grade with the largest improvement increased by 10.4 points. It can be seen that the music teaching method with dramatic elements can significantly improve the students' music performance.