Just put the attribute in the class definition.
But how to do this, since your file can be overridden at any time. Use a separate file, since all generated classes are partial classes. Open a separate file and write something like:
[GeneratedCode("EntityModelCodeGenerator", "4.0.0.0")] public partial class YourEntitiesContextName : ObjectContext { }
This will skip the code analysis for your specific generated class. StyleCop, for example, is smarter and does not apply to files that have a .designer/.generated part in their name or regions that have a generated word in their name.
Robert Koritnik
source share