Nowadays generation of reliable patterns is a challenge in the software engineering field, so determination of the anti-patterns becomes an effective and objective concept to evaluate any design. This paper proposes a general method to detect anti-patterns; structure and semantics in case of UML(Unified modeling language) class diagram. The proposed method is classified as a hybrid between mathematical and meta-model approaches. Its four phases merge between OWL(Web Ontology Language) Ontologybased and event B for detection many anti-patterns; semantic and structure in UML class diagram components (attributes, classes, operations, and associations). The paper proves the proposed method in two ways; the first way is theoretical by coupling UML components with OWL and Event-B. The second way is experimental by applying the method on a sample of nine famous UML class diagrams used as templates. The method detects and corrects the anti-patterns which appeared 519 times.