Given a graph F and an integer r >= 2, a partition (F) over cap of the edge set of F into at most r classes, and a graph G, define c(r,(F) over cap)(G) as the number of r-colorings of the edges of G that do not contain a copy of F such that the edge partition induced by the coloring is isomorphic to the one of F. We think of (F) over cap as the pattern of coloring that should be avoided. The main question is, for a large enough n, to find the (extremal) graph G on n vertices which maximizes c(r,(F) over cap)(G). This problem generalizes a question of Erdos and Rothschild, who originally asked about the number of colorings not containing a monochromatic clique (which is equivalent to the case where F is a clique and the partition (F) over cap contains a single class). We use Holder's Inequality together with Zykov's Symmetrization to prove that, for any r >= 2, k >= 3 and any pattern (K) over cap (k) of the clique K-k, there exists a complete multipartite graph that is extremal. Furthermore, if the pattern (K) over cap (k) has at least two classes, with the possible exception of two very small patterns (on three or four vertices), every extremal graph must be a complete multipartite graph. In the case that r = 3 and (F) over cap is a rainbow triangle (that is, where F = K-3 and each part is a singleton), we show that an extremal graph must be an almost complete graph. Still for r = 3, we extend a result about monochromatic patterns of Alon, Balogh, Keevash and Sudakov to some patterns that use two of the three colors, finding the exact extremal graph. For the later two results, we use the Regularity and Stability Method. (C) 2017 Elsevier B.V. All rights reserved.