Code contracts. How suppress warnings on generated code?
How can I turn off static checks on my Linq2Sql code? You can suppress checks on static code by marking the class(es) in question with [ContractVerification(false)] . If your generated classes are partial you can create another file with another part(ial) in it and add it there, so it doesn't get overwritten when the code is regenerated. 来源: https://stackoverflow.com/questions/3662293/code-contracts-how-suppress-warnings-on-generated-code