Skip to content

Settings.UsePragma

Simon Hughes edited this page Aug 30, 2026 · 1 revision

Settings.UsePragma

Adds #pragma warning disable 1591 to the top of each generated file, silencing the "missing XML comment" warning.

Type bool
Default false
Applies to EF 6 and EF Core
Databases All
In Database.tt? Yes

What it does

Exactly one line:

// <auto-generated>
#pragma warning disable 1591    //  Ignore "Missing XML Comment" warning
using Microsoft.Data.SqlClient;

Warning 1591 is "Missing XML comment for publicly visible type or member". It only fires in a project that has <GenerateDocumentationFile>true</GenerateDocumentationFile>, and in such a project a generated file with sixty undocumented public properties produces sixty warnings you will never act on.

When to use it

Turn it on if your project generates an XML documentation file. Otherwise the generated code buries the warnings you actually care about.

Leave it off otherwise. With no documentation file, warning 1591 never fires and the pragma is a line that does nothing.

A .editorconfig rule scoped to the generated file is the tidier alternative if you already maintain one:

[Database.cs]
dotnet_diagnostic.CS1591.severity = none

That keeps the suppression in your configuration rather than in generated output, and it survives if you later turn this setting off.

Gotchas

It disables only warning 1591. Anything else the generated code triggers - unused usings, naming rules, nullable warnings - is untouched. Settings.UseResharper covers a different set, and Settings.AllowNullStrings is what silences the nullable ones.

It is never restored. There is no matching #pragma warning restore, so the suppression applies to the whole file. That is fine for a file you do not edit, and worth knowing if you were expecting it to be scoped.

Turning on Settings.IncludeComments = CommentsStyle.InSummaryBlock does not remove the need for it. Most properties get a <summary> that way, but not all members do, so a project requiring documentation still warns.

See also

Clone this wiki locally