-
Notifications
You must be signed in to change notification settings - Fork 226
Settings.ShowLicenseInfo
Settings.ShowLicenseInfo, Settings.IncludeGeneratorVersionInCode and Settings.IncludeConnectionSettingComments
Three settings controlling what provenance information the generated file carries about itself.
| Setting | Type | Default | Writes |
|---|---|---|---|
Settings.ShowLicenseInfo |
bool |
false |
Your licence details as a header comment |
Settings.IncludeGeneratorVersionInCode |
bool |
false |
The generator version. Needs ShowLicenseInfo on too
|
Settings.IncludeConnectionSettingComments |
bool |
false |
The database edition and version read at generation time |
All three are in Database.tt and apply everywhere.
ShowLicenseInfo adds a comment naming who the generator is licensed to. Useful if you want the
provenance recorded in the source; noise otherwise.
IncludeGeneratorVersionInCode adds the generator's version number - but only when ShowLicenseInfo is
also true. On its own it does nothing, which is the single most confusing thing about these three.
IncludeConnectionSettingComments records what the generator found when it connected:
// Database Edition : Developer Edition (64-bit)
// Database Engine Edition: Enterprise
// Database Version : 14.0.3540.1That is genuinely useful when a generated file behaves differently on two machines. Several features are
version-gated - temporal tables need SQL Server 2016, json and vector need 2025 - so "which server was
this generated against?" is a real question with a real answer here.
IncludeConnectionSettingComments on a shared codebase. If more than one person regenerates, recording
which server produced the file turns "why does your output differ from mine?" into a two-second check.
ShowLicenseInfo and IncludeGeneratorVersionInCode together for auditability - which generator version
produced this file, under which licence. Worth it in a regulated environment and pointless otherwise.
Leave all three off by default, which is what the shipped .tt does. Every one of them adds churn: the
version changes when you upgrade, the connection details change when you generate from a different server,
and a diff full of comment changes hides the real change.
IncludeGeneratorVersionInCode does nothing on its own. It is gated on ShowLicenseInfo. Turn both on.
They add diff noise. IncludeConnectionSettingComments in particular changes whenever anyone patches the
database server, so a routine SQL Server update shows up as a change to every generated file.
ShowLicenseInfo writes licence details into source control. It is your name and company, not a key, so it
is not a secret - but it is personal data appearing in a public repository if the project is open source.
Azure SQL reports differently. IncludeConnectionSettingComments shows the Azure engine edition rather
than an on-premises one, which is correct and looks odd the first time.
[GeneratedCode] is a different setting.
Settings.IncludeCodeGeneratedAttribute records the version as an
attribute on each class, for tooling rather than for humans, and does not need ShowLicenseInfo.
- Settings.IncludeCodeGeneratedAttribute - the machine-readable version
- Settings.AdditionalFileHeaderText - your own header lines
- Licencing & expires licence
- SQL Server - the version-gated features these comments help you diagnose
- Settings Reference
- Home
- Compared with the Microsoft scaffolder
- Connection strings
- JetBrains Rider
- Upgrading from v3 to v4
- Saving .tt does nothing
- Settings A-Z - every setting, with a page each
- Common Settings Types Explained
- Settings Callbacks
- Settings runtime values and helpers
- Filtering
- Full Control Over the Generated Code
- Enum Generation from Table Data
- Owned Entities
- JSON column support
- Global Query Filters
- Extended Property Names Feature
- Partial Properties
- File-Scoped Namespaces
- Data Annotations
- Spatial Types
- HierarchyId
- RowVersion and TimeStamp columns
- Lazy Loading
- Stored proc result sets