Table of Contents

Class DataModelOptions

Namespace
LinqToDB.Scaffold
Assembly
linq2db.Tools.dll

Data model-related options.

public sealed class DataModelOptions
Inheritance
DataModelOptions
Extension Methods

Properties

AssociationCollectionAsArray

Enables use of array as collection type for association properties/methods. Otherwise see AssociationCollectionType setting.

  • Default: false
  • In T4 compability mode: false
public bool AssociationCollectionAsArray { get; set; }

Property Value

bool

AssociationCollectionType

When specified, many-sided association property/method will use specified type as return type. Type must be open generic type with one type argument, e.g. IEnumerable<T>, List<T> or ICollection<T>. E.g.

"System.Collections.Generic.List<>"
If not configured, IEnumerable<T> type will be used. Option ignored if AssociationCollectionType set to true.
  • Default: not set
  • In T4 compability mode: not set
public string? AssociationCollectionType { get; set; }

Property Value

string

AsyncProcedureResultClassNameOptions

Gets or sets name generation and normalization rules for custom mapping class for async stored procedure results wrapper for procedure with multiple returns.

public NormalizationOptions AsyncProcedureResultClassNameOptions { get; set; }

Property Value

NormalizationOptions

AsyncProcedureResultClassPropertiesNameOptions

Gets or sets name generation and normalization rules for custom mapping class properties for async stored procedure results wrapper for procedure with multiple returns.

public NormalizationOptions AsyncProcedureResultClassPropertiesNameOptions { get; set; }

Property Value

NormalizationOptions

BaseContextClass

Gets or sets type name (full name with namespace) of base class for generated data context. When not specified, DataConnection type used. Provided type should implement IDataContext interface and it is recommented to use wether DataConnection or DataContext classes or classes, derived from them.

  • Default: not set
  • In T4 compability mode: not set
public string? BaseContextClass { get; set; }

Property Value

string

BaseEntityClass

Gets or sets name of class to use as base class for generated entities. Must be a full type name with namespace. If type is nested, it should use + for type separator, e.g. "My.NameSpace.SomeClass+BaseEntity" Current limitaion - type cannot be generic.

  • Default: null
  • In T4 compability mode: null
public string? BaseEntityClass { get; set; }

Property Value

string

ContextClassName

Gets or sets name of data context class. When not set, database name will be used. If database name not provided by schema provider, "MyDataContext" used as name.

  • Default: not set
  • In T4 compability mode: not set
public string? ContextClassName { get; set; }

Property Value

string

DataContextClassNameOptions

Gets or sets name generation and normalization rules for data context class name when name not provided by user but generated automatically.

public NormalizationOptions DataContextClassNameOptions { get; set; }

Property Value

NormalizationOptions

EntityClassIsPartial

Enables partial class modifier applied to entity mapping classes.

  • Default: false
  • In T4 compability mode: true
public bool EntityClassIsPartial { get; set; }

Property Value

bool

EntityClassNameOptions

Gets or sets name generation and normalization rules for entity classes.

public NormalizationOptions EntityClassNameOptions { get; set; }

Property Value

NormalizationOptions

EntityClassNameProvider

Gets or sets custom name generator for entity class name.

  • Default: not set
  • In T4 compability mode: not set
public Func<TableLikeObject, string?>? EntityClassNameProvider { get; set; }

Property Value

Func<TableLikeObject, string>

EntityColumnPropertyNameOptions

Gets or sets name generation and normalization rules for entity column properties.

public NormalizationOptions EntityColumnPropertyNameOptions { get; set; }

Property Value

NormalizationOptions

EntityContextPropertyNameOptions

Gets or sets name generation and normalization rules for entity table access property in data context class.

public NormalizationOptions EntityContextPropertyNameOptions { get; set; }

Property Value

NormalizationOptions

EntityContextPropertyNameProvider

Gets or sets custom name generator for data context property name to access entity table.

  • Default: not set
  • In T4 compability mode: not set
public Func<TableLikeObject, string?>? EntityContextPropertyNameProvider { get; set; }

Property Value

Func<TableLikeObject, string>

FindParameterNameOptions

Gets or sets name generation and normalization rules for Find entity extension method parameters.

public NormalizationOptions FindParameterNameOptions { get; set; }

Property Value

NormalizationOptions

FunctionTupleResultClassNameOptions

Gets or sets name generation and normalization rules for mapping class for result tuple value of scalar function.

public NormalizationOptions FunctionTupleResultClassNameOptions { get; set; }

Property Value

NormalizationOptions

FunctionTupleResultPropertyNameOptions

Gets or sets name generation and normalization rules for field properies of result tuple value mapping class of scalar function.

public NormalizationOptions FunctionTupleResultPropertyNameOptions { get; set; }

Property Value

NormalizationOptions

GenerateAssociationExtensions

Enables generation of associations for foreign keys as extension methods (with entity as extended type).

  • Default: false
  • In T4 compability mode: false
public bool GenerateAssociationExtensions { get; set; }

Property Value

bool

GenerateAssociations

Enables generation of associations for foreign keys as entity properties.

  • Default: true
  • In T4 compability mode: true
public bool GenerateAssociations { get; set; }

Property Value

bool

GenerateDataType

Enables generation of DataType enum value for entity column mapping.

  • Default: false
  • In T4 compability mode: false
public bool GenerateDataType { get; set; }

Property Value

bool

GenerateDbType

Enables generation of database type name for entity column mapping.

  • Default: false
  • In T4 compability mode: false
public bool GenerateDbType { get; set; }

Property Value

bool

GenerateDefaultSchema

Enables generation of Schema name for default schemas in mappings (for tables, views, procedures and functions).

  • Default: false
  • In T4 compability mode: true
public bool GenerateDefaultSchema { get; set; }

Property Value

bool

GenerateFindExtensions

Enables generation of extension methods to access entity by primary key value (using name Find/FindAsync/FindQuery for generated method).

public FindTypes GenerateFindExtensions { get; set; }

Property Value

FindTypes

GenerateIEquatable

Enables generation of IEquatable<T> interface implementation on entity classes with primary key.

  • Default: false
  • In T4 compability mode: false
public bool GenerateIEquatable { get; set; }

Property Value

bool

GenerateInitDataContextMethod

Enables generation of InitDataContext partial method on data context class.

  • Default: true
  • In T4 compability mode: true
public bool GenerateInitDataContextMethod { get; set; }

Property Value

bool

GenerateLength

Enables generation of database type length for entity column mapping.

  • Default: false
  • In T4 compability mode: false
public bool GenerateLength { get; set; }

Property Value

bool

GeneratePrecision

Enables generation of database type precision for entity column mapping.

  • Default: false
  • In T4 compability mode: false
public bool GeneratePrecision { get; set; }

Property Value

bool

GenerateProcedureAsync

Enables generation of async version of stored procedure mapping.

  • Default: true
  • In T4 compability mode: false
public bool GenerateProcedureAsync { get; set; }

Property Value

bool

GenerateProcedureParameterDbType

Enables generation of database type name in stored procedure parameter mapping.

  • Default: false
  • In T4 compability mode: false
public bool GenerateProcedureParameterDbType { get; set; }

Property Value

bool

GenerateProcedureResultAsList

When true, stored procedure mapping use List<T> as return type. Otherwise IEnumerable<T> type used.

  • Default: false
  • In T4 compability mode: false
public bool GenerateProcedureResultAsList { get; set; }

Property Value

bool

GenerateProcedureSync

Enables generation of sync version of stored procedure mapping.

  • Default: true
  • In T4 compability mode: true
public bool GenerateProcedureSync { get; set; }

Property Value

bool

GenerateProceduresSchemaError

Enables generation of error if stored procedure or table function schema load failed.

  • Default: false
  • In T4 compability mode: false
public bool GenerateProceduresSchemaError { get; set; }

Property Value

bool

GenerateScale

Enables generation of database type scale for entity column mapping.

  • Default: false
  • In T4 compability mode: false
public bool GenerateScale { get; set; }

Property Value

bool

GenerateSchemaAsType

Enables generation of context for entities and procedures/functions from non-default schemas in separate context-like class.

  • Default: true
  • In T4 compability mode: false
public bool GenerateSchemaAsType { get; set; }

Property Value

bool

HasConfigurationConstructor

Enables generation of data context constructor with (string configurationName) parameter.

  • Default: true
  • In T4 compability mode: true
public bool HasConfigurationConstructor { get; set; }

Property Value

bool

HasDefaultConstructor

Enables generation of default data context constructor.

  • Default: true
  • In T4 compability mode: true
public bool HasDefaultConstructor { get; set; }

Property Value

bool

HasTypedOptionsConstructor

Enables generation of data context constructor with generic (DataOptions<T> options) parameter, where T is generated data context class.

  • Default: true
  • In T4 compability mode: true
public bool HasTypedOptionsConstructor { get; set; }

Property Value

bool

HasUntypedOptionsConstructor

Enables generation of data context constructor with non-generic (DataOptions options) parameter.

  • Default: false
  • In T4 compability mode: true
public bool HasUntypedOptionsConstructor { get; set; }

Property Value

bool

IncludeDatabaseInfo

Enables generation of comment with database information on data context class. Includes database name, data source and server version values if available from schema provider for current database.

  • Default: false
  • In T4 compability mode: false
public bool IncludeDatabaseInfo { get; set; }

Property Value

bool

IncludeDatabaseName

Enables generation of Database name in mappings (for tables, views, procedures and functions).

  • Default: false
  • In T4 compability mode: false
public bool IncludeDatabaseName { get; set; }

Property Value

bool

MapProcedureResultToEntity

Enables reuse of generated entity mapping class and stored procedure or table function return record type, when record mappings match known entity mappings (record has same set of columns by name and type including nullability as entity).

  • Default: true
  • In T4 compability mode: true
public bool MapProcedureResultToEntity { get; set; }

Property Value

bool

Metadata

Specifies type of generated metadata source.

public MetadataSource Metadata { get; set; }

Property Value

MetadataSource

OrderFindParametersByColumnOrdinal

Specifies order of primary key column parameters in Find method for entity with composite primary key.

  • Default: true
  • In T4 compability mode: false
public bool OrderFindParametersByColumnOrdinal { get; set; }

Property Value

bool

ProcedureNameOptions

Gets or sets name generation and normalization rules for stored procedures and functions method names.

public NormalizationOptions ProcedureNameOptions { get; set; }

Property Value

NormalizationOptions

ProcedureParameterNameOptions

Gets or sets name generation and normalization rules for stored procedures and functions method parameters.

public NormalizationOptions ProcedureParameterNameOptions { get; set; }

Property Value

NormalizationOptions

ProcedureResultClassNameOptions

Gets or sets name generation and normalization rules for custom mapping class for result record of stored procedure or table function.

public NormalizationOptions ProcedureResultClassNameOptions { get; set; }

Property Value

NormalizationOptions

ProcedureResultColumnPropertyNameOptions

Gets or sets name generation and normalization rules for column properties of custom mapping class for result record of stored procedure or table function.

public NormalizationOptions ProcedureResultColumnPropertyNameOptions { get; set; }

Property Value

NormalizationOptions

SchemaClassNameOptions

Gets or sets name generation and normalization rules for wrapper class for non-default schema (when GenerateSchemaAsType option enabled).

public NormalizationOptions SchemaClassNameOptions { get; set; }

Property Value

NormalizationOptions

SchemaMap

Provides base names for schema wrapper class and main data context property for additional schemas (when GenerateSchemaAsType option set).

  • Default: empty
  • In T4 compability mode: empty
public IDictionary<string, string> SchemaMap { get; }

Property Value

IDictionary<string, string>

SchemaPropertyNameOptions

Gets or sets name generation and normalization rules for non-default schema data context class accessor property on main data context (when GenerateSchemaAsType option enabled).

public NormalizationOptions SchemaPropertyNameOptions { get; set; }

Property Value

NormalizationOptions

SkipProceduresWithSchemaErrors

Skip generation of mappings for stored procedure, if it failed to load it's schema. Otherwise mapping will be generated, but procedure will have only parameters without return data sets. This option doesn't affect table functions with schema errors - for functions we skip them on error always, because table function must have return result set.

  • Default: false
  • In T4 compability mode: true
public bool SkipProceduresWithSchemaErrors { get; set; }

Property Value

bool

SourceAssociationPropertyNameOptions

Gets or sets name generation and normalization rules for assocation from foreign key source entity side.

public NormalizationOptions SourceAssociationPropertyNameOptions { get; set; }

Property Value

NormalizationOptions

TableFunctionMethodInfoFieldNameOptions

Gets or sets name generation and normalization rules for field to store MethodInfo for table function mapping method.

public NormalizationOptions TableFunctionMethodInfoFieldNameOptions { get; set; }

Property Value

NormalizationOptions

TableFunctionReturnsTable

When true, table function mapping use ITable<T> as return type. Otherwise IQueryable<T> type used.

  • Default: false
  • In T4 compability mode: true
public bool TableFunctionReturnsTable { get; set; }

Property Value

bool

TargetMultipleAssociationPropertyNameOptions

Gets or sets name generation and normalization rules for assocation from foreign key target entity side with multiple cardinality.

public NormalizationOptions TargetMultipleAssociationPropertyNameOptions { get; set; }

Property Value

NormalizationOptions

TargetSingularAssociationPropertyNameOptions

Gets or sets name generation and normalization rules for assocation from foreign key target entity side with singular cardinality.

public NormalizationOptions TargetSingularAssociationPropertyNameOptions { get; set; }

Property Value

NormalizationOptions