-
Notifications
You must be signed in to change notification settings - Fork 226
Settings Reference
Every setting in Database.tt, A to Z, with a one-line summary and a link to its page.
Each page shows the generated code before and after, produced by running the generator rather than typed from memory, and re-checked by a test so it cannot quietly stop being true.
Settings that are always set together, or that only make sense read together, share a page - the two collection settings, the five class modifier settings, the three connection string settings. The link takes you to the right place either way.
New to the generator, or working out why something is not happening:
- Settings.DatabaseType, TemplateType and GeneratorType - the three you must get right first
- Settings.ConnectionString and friends - and why there are three of them
- Settings.ElementsToGenerate - which classes get generated at all
- Settings.GenerateSeparateFiles - one file or many
- Settings.UpdateColumn - the main hook for reshaping the model
- Filtering - which tables and columns are read in the first place
Related pages that cover a whole topic rather than one setting: Settings Callbacks | Common Settings Types Explained | Full Control Over the Generated Code | Settings runtime values and helpers
| Setting | What it does |
|---|---|
Settings.AddEnum |
Decide which tables become enums, by rule |
Settings.AddEnumDefinitions |
Replace a column's type with an enum |
Settings.AddExtraForeignKeys |
Relationships the database does not declare |
Settings.AddIDbContextFactory |
Generates the factory dotnet ef looks for |
Settings.AdditionalContextInterfaceItems |
Extra members on the context interface |
Settings.AdditionalFileFooterText |
Your own lines at the bottom |
Settings.AdditionalFileHeaderText |
Your own lines at the top of each file |
Settings.AdditionalForeignKeysDataAnnotations |
Attributes on every foreign key property |
Settings.AdditionalNamespaces |
Extra using lines |
Settings.AdditionalReverseNavigationsDataAnnotations |
Attributes on every reverse navigation |
Settings.AddJsonColumnMappings |
Map a JSON column to a real class |
Settings.AddOwnedEntityMappings |
Group prefixed columns into an owned entity |
Settings.AddParameterlessConstructorToDbContext |
EF 6. Whether a parameterless constructor is generated |
Settings.AddUnitTestingDbContext |
Generates FakeDbContext and FakeDbSet |
Settings.AllowNullStrings |
string? and #nullable enable
|
Settings.CollectionInterfaceType |
The declared collection type: ICollection, IList |
Settings.CollectionType |
The concrete collection type: List, ObservableCollection, HashSet |
Settings.ColumnIdentity |
The fluent call after ValueGeneratedOnAdd() |
Settings.CommandTimeout |
How long each schema query may take, in seconds |
Settings.ConfigurationClassesModifiers |
Modifiers on configuration classes |
Settings.ConfigurationClassName |
Suffix for configuration classes: Configuration, Map, Mapping |
Settings.ConnectionString |
The connection string the generator uses at design time |
Settings.ConnectionStringActions |
Extra fluent calls appended to the provider setup |
Settings.ConnectionStringName |
A key your application looks up at run time |
Settings.ContextFolder |
Sub-folder for the DbContext |
Settings.ContextNamespace |
A using for where the DbContext lives |
Settings.DatabaseType |
Which database to read: SqlServer, PostgreSQL, MySql, Oracle, SQLite |
Settings.DbContextBaseClass |
What the context inherits from, e.g. IdentityDbContext |
Settings.DbContextClassModifiers |
Modifiers on the context. partial enables OnModelCreatingPartial |
Settings.DbContextInterfaceBaseClasses |
What the interface extends |
Settings.DbContextInterfaceModifiers |
Modifiers on the interface |
Settings.DbContextInterfaceName |
The interface name; empty string means no interface |
Settings.DbContextName |
The generated context class name |
Settings.DefaultConstructorArgument |
EF 6. What the parameterless constructor passes to base |
Settings.DefaultSchema |
The schema that is never prepended. Set by the reader |
Settings.DisableGeographyTypes |
Skips spatial columns. On by default |
Settings.ElementsToGenerate |
Which kinds of class to generate at all |
Settings.EntityClassesModifiers |
Modifiers on entity classes - usually public partial
|
Settings.Enumerations |
Turn a lookup table's rows into a C# enum |
Settings.FakeDbContextInDebugOnlyMode |
Wraps the fakes in #if DEBUG
|
Settings.FileExtension |
The extension on generated files |
Settings.FilterCount |
How many contexts the run produced. Read-only |
Settings.ForeignKeyAnnotationsProcessing |
Attributes on navigation properties |
Settings.ForeignKeyFilterFunc |
Drop a relationship, or just its reverse navigation |
Settings.ForeignKeyName |
Name the navigation properties |
Settings.GenerateHasDefaultValueSql |
EF Core. Defaults in the EF model, not just the POCO |
Settings.GenerateSeparateFiles |
One file per class instead of one big Database.cs |
Settings.GenerateSingleDbContext |
One context, or many driven by database settings tables |
Settings.GenerationLanguage |
C# or the experimental Javascript type map |
Settings.GeneratorType |
Which generation engine runs. Must be paired with TemplateType |
Settings.HiLoSequences |
Client-side id blocks from a database sequence |
Settings.IncludeCodeGeneratedAttribute |
[GeneratedCode] on each class |
Settings.IncludeColumnsWithDefaults |
Copies database defaults into the POCO |
Settings.IncludeComments |
Column names, keys and lengths as comments |
Settings.IncludeConnectionSettingComments |
Database edition and version at generation time |
Settings.IncludeExtendedPropertyComments |
Your database's own column descriptions |
Settings.IncludeFieldNameConstants |
A const string per property holding its own name |
Settings.IncludeGeneratorVersionInCode |
The generator version. Needs ShowLicenseInfo too |
Settings.IncludeQueryTraceOn9481Flag |
Works around the SQL Server 2014 cardinality estimator |
Settings.InterfaceFolder |
Sub-folder for the interface |
Settings.InterfaceNamespace |
A using for where the interface lives |
Settings.MappingTableRename |
Name collections from a many-to-many table |
Settings.MergeMultipleStoredProcModelsIfAllSame |
Collapses identical result sets into one |
Settings.MultiContextAllFieldsColumnProcessing |
Read your own columns from the settings tables |
Settings.MultiContextAllFieldsFunctionProcessing |
The same, per function |
Settings.MultiContextAllFieldsStoredProcedureProcessing |
The same, per stored procedure |
Settings.MultiContextAllFieldsTableProcessing |
The same, per table |
Settings.MultiContextAttributeDelimiter |
Separator for several attributes in one settings column |
Settings.MultiContextSettingsConnectionString |
Where the MultiContext.* tables live |
Settings.MultiContextSettingsPlugin |
Your own multi-context settings reader |
Settings.Namespace |
The namespace all generated code goes into |
Settings.NullableReverseNavigationProperties |
Nullable reverse navigation on one-to-one |
Settings.NullableShortHand |
int? rather than Nullable<int>
|
Settings.OnConfiguration |
EF Core. Connection string, IConfiguration, or nothing |
Settings.OrderProperties |
Column order or alphabetical |
Settings.OwnedEntityFolder |
Sub-folder for owned entity classes |
Settings.PocoConfigurationFolder |
Sub-folder for the configuration classes |
Settings.PocoConfigurationNamespace |
A using for where the configurations live |
Settings.PocoFolder |
Sub-folder for the entity classes |
Settings.PocoNamespace |
A using for where the entities live |
Settings.PrependSchemaName |
sales.Order becomes sales_Order
|
Settings.PrependSchemaNameForStoredProcedure |
Per-procedure control of the above |
Settings.PrependSchemaNameForTable |
Per-table control of the above |
Settings.ReadStoredProcReturnObjectCompleted |
Adjust a discovered result shape |
Settings.ReadStoredProcReturnObjectException |
Handle a failed result-shape discovery |
Settings.ResultClassModifiers |
Modifiers on stored procedure return models |
Settings.Root |
The folder holding your .tt file. Read-only |
Settings.ShowLicenseInfo |
Licence details in the file header |
Settings.StoredProcedureRename |
Rename the generated method |
Settings.StoredProcedureReturnModelRename |
Rename the generated result class |
Settings.StoredProcedureReturnTypes |
Return an entity you already have |
Settings.TableRename |
Rename a table before anything else happens to it |
Settings.TableSuffix |
Appends a suffix to every entity class name |
Settings.TemplateFile |
The .tt file name. Read-only |
Settings.TemplateFolder |
Where the Mustache templates are, for FileBased templates |
Settings.TemplateType |
Which code templates to use. Match your EF version, not your .NET version |
Settings.TrimCharFields |
EF Core. TrimEnd() on char columns |
Settings.UpdateColumn |
Rename, retype, hide or annotate a column |
Settings.UpdateEnum |
Attributes on the generated enum |
Settings.UpdateEnumMember |
Attributes on each enum member |
Settings.UpdateTable |
Base classes, attributes, or drop the table |
Settings.UseDataAnnotations |
Adds [Key], [Required], [MaxLength] and friends |
Settings.UseFileScopedNamespaces |
namespace X; instead of namespace X { }
|
Settings.UseFolderNameInNamespace |
Makes the namespace follow the output folder |
Settings.UseInheritedBaseInterfaceFunctions |
Take the interface members from a base interface instead |
Settings.UseLazyLoading |
Marks navigation properties virtual
|
Settings.UseMappingTables |
EF 6. Map many-to-many implicitly |
Settings.UseNamespace |
Suppresses the namespace declaration entirely |
Settings.UsePascalCase |
order_line_item becomes OrderLineItem
|
Settings.UsePascalCaseForEnumMembers |
The same, for enum member names |
Settings.UsePragma |
#pragma warning disable 1591 |
Settings.UsePrivateSetterForComputedColumns |
private set; on computed columns |
Settings.UsePropertiesForStoredProcResultSets |
Properties rather than fields on multi-result-set models |
Settings.UsePropertyInitialisers |
Property initialisers instead of a constructor |
Settings.UseRegions |
#region blocks in single-file output |
Settings.UseResharper |
// ReSharper disable All. On by default
|
Settings.ViewProcessing |
Declare which columns identify a row in a view |
Settings.WriteInsideClassBody |
Inject C# into every entity class |
- 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