Reference > Configuration > Scaffolding
Object Overrides
The overrides setting is an array of override object definitions. These overrides allow detailed control of the generated scaffolding.
Order of overrides matters
Scaffold configuration uses a "last one wins strategy", so the order of the apply
objects provided in the configuration file can be adjusted to result in the desired scaffolding output.
The following pseudo-json shows all the possible overrides available in the apply
object.
{
"apply": {
"ignore": true|false,
"name": "{a different name for the entity}",
"clrType": "{clr type name for properties of the entity}",
"baseType": "{type name the entity should extend}",
"allowInsert": true|false,
"allowUpdate": true|false,
"interfaces": {
"add": [ "{list of interface type names the entity should implement}" ],
"remove": [ "{list of interface type names to remove from the entity's implementations}" ]
},
"to": {
"path": "{the schema path to apply the override}",
"objectType": "{Schema|Table|View|Column|TableColumn|ViewColumn|Procedure|Parameter}"
}
}
}
apply.ignore
Setting ignore
to true
instructs the code generation tool to completely ignore creating any code for the target.
Data type | bool |
Default value | false |
Applicable to | database object types
|
apply.name
Allows for overriding SQL object names during the code generation process. Database engines typically have far fewer restrictions on object names than what is allowed for class names or property names in the .NET CLR, use the name
property to ensure C# compliant property names.
Data type | bool |
Default value | false |
Applicable to | database object types
|
apply.clrType
Allows for overriding the default mapped CLR type. Mapping enumeration values to SQL string or integer is the most common use for the clrType
override setting. If the override value is a standard .NET CLR type (i.e. int
, int?
, string
, DateTime
, DateTime?
, long
, etc.) then you do not need to fully qualify the type name. However, if the type is a custom type (like an Enum
), the type name must be a fully qualified type name.
Data type | string |
Default value | actual object name from SQL schema |
Applicable to | database object types
|
apply.baseType
Specify a type all generated POCO class(es) matching the path
parameter should extend. The type name must be a fully qualified type name.
Data type | string |
Default value | null |
Applicable to | database object types
|
apply.allowInsert
Allows flagging a column as not insertable. Setting allowInsert
to false
tells the code generation process to ignore creating the scaffold code required to directly insert the column value. The most common use for this override is for table columns that are controlled by defaults or they are defined as computed columns.
Data type | bool |
Default value | true |
Applicable to | database object types
|
apply.allowUpdate
Allows flagging a column as not updateable. Setting allowUpdate
to false
tells the code generation process to ignore creating the scaffold code required to directly update the column. The most common use for this override is for table columns that are controlled by triggers or they are defined as computed columns.
Data type | bool |
Default value | true |
Applicable to | database object types
|
apply.interfaces
Allows the addition and removal of one or more interfaces that are applied to the generated POCO class(es) matching the path
parameter. The interface names must be fully qualified (include the namespace). Use of add/remove enables fine grained control of interfaces applied to the set of matching POCO classes. For each apply
, interfaces provided through remove
are processed after add
, and apply
's are processed in the order they are provided in the configuration file (see syntax examples).
Applicable to | database object types
|
apply.interfaces.add
The list of interfaces to add to all POCOs matching the path
parameter.
Data type | string[] |
Default value | empty array |
apply.interfaces.remove
The list of interfaces to remove from all POCOs matching the path
parameter.
Data type | string[] |
Default value | empty array |
apply.to.path
The path
value is used to resolve the set of objects to which the override is applied. The format of the value follows the top down flow of the objects within a database: schema.table|view.column. The *
(asterisk) character can be used within a path as a wildcard. Providing a path of .
(single period) will resolve the database object.
Data type | string |
Default value | null |
Applicable to | database object types
|
apply.to.objectType
The objectType
value can be provided along with the path
value to narrow the focus of the resolved items to a specific type of database object. Allowed values are Schema, Table, View, Column, TableColumn, ViewColumn, Procedure, Parameter (case insensitive).
Data type | string |
Default value | null |
Applicable to | database object types
|