28 February 2012

Suppress EF Compiler Warnings Error 11007 and 11008

I am working on an MVVM project that parses records out of encrypted data files, on demand.  There is no real data source for this project, for Entity Framework 4.1 to reference.  Every time I build the model assembly, I get a huge pile of warnings for Error 11007 and 11008.

Because I am a savvy developer (and slightly obsessive-compulsive), I don't want to see any compiler warnings after a build.  Because I know these are non-issue warnings, I can safely disable them.  Here's how to disable EF warnings in your projects:
First, the following are examples of these warnings (formatted to fit nicely on this page).  These noremally appear in Visual Studio's Error List window:

Warning 26
Error 11007: Entity type 'LookupCode' is not mapped.
164
9
C:\development\MyProject\Main\Source\MyProject.Model\EntityModel.edmx
MyProject.Model


Warning 37
Error 11008: Association 'LookupCodeCustomer_MaritalStatus' is not mapped.
345
9
C:\development\MyProject\Main\Source\MyProject.Model\EntityModel.edmx
MyProject.Model

These warnings are easily suppressed, by following these steps:

  1. Double-click the entity model in Visual Studio's Solution Explorer window, to open the model in the model designer
  2. If the Properties window is not already visible, press the F4 key
  3. Change the "Validate On Build" property to FALSE
  4. Save changes to the model
You're all set to go, warning free.  Happy coding!

3 comments:

Please provide details, when posting technical comments. If you find an error in sample code or have found bad information/misinformation in a post, please e-mail me details, so I can make corrections as quickly as possible.