What's the right way to suppress EF warnings?

You are correct that these are warnings, not errors. The easiest way to supress the validation warnings from the compiler is to disable the Validate on Build property of the EF model. To do so, open your .edmx and select the background. Open the Properties window of Visual Studio and set Validate on Build to false. When you want to validate the model, just open the model again. There is also a right click context menu option on the model to Validate.


Even better would be to create a .editorconfig file yourself, either at the solution level or at the project level, and add rules such as Erik has mentioned in his post. As mentioned in this answer, you can add an EditorConfig file, which will already bring some other rules and good practices into your project or solution, if you pick the .NET option.


  • From the menu bar, choose Project > Add New Item; or press Ctrl+Shift+A

  • Select the editorconfig File (.NET) template to add an EditorConfig file prepopulated with default .NET code style, formatting, and naming conventions

enter image description here


However, to completely suppress warnings or suggestions, you should use 'none' instead of 'suggestion'. For example, for the CA1707, which shows a warning every time a method name contains an '_', you would need to add the following entry in the .editorconfig file:

[*.cs]
dotnet_diagnostic.CA1707.severity = none

However, I do like this rule. Except when applied in Test projects, which by convention end up with 'Tests.cs'. I could then refine my rule, to consider that case:

[*Tests.cs]
dotnet_diagnostics.CA1707.severity = none

With the latest rule, I can then go for a solution level .editorconfig file, which will apply that rule only to Test projects.