Table of Contents

Class RelationalModelBuilderExtensions

Namespace
Microsoft.EntityFrameworkCore
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

Relational database specific extension methods for Microsoft.EntityFrameworkCore.ModelBuilder.

public static class RelationalModelBuilderExtensions
Inheritance
RelationalModelBuilderExtensions
Inherited Members

Methods

CanSetCollation(IConventionModelBuilder, string, bool)

Returns a value indicating whether the given collation can be set as default.

public static bool CanSetCollation(this IConventionModelBuilder modelBuilder, string collation, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

collation string

The collation.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

bool

true if the given collation can be set as default.

CanSetDefaultSchema(IConventionModelBuilder, string, bool)

Returns a value indicating whether the given schema can be set as default.

public static bool CanSetDefaultSchema(this IConventionModelBuilder modelBuilder, string schema, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

schema string

The default schema.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

bool

true if the given schema can be set as default.

CanSetMaxIdentifierLength(IConventionModelBuilder, int?, bool)

Returns a value indicating whether the maximum length allowed for store identifiers can be set.

public static bool CanSetMaxIdentifierLength(this IConventionModelBuilder modelBuilder, int? length, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

length int?

The value to set.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

bool

true if the maximum length allowed for store identifiers can be set.

HasDbFunction(IConventionModelBuilder, MethodInfo, bool)

Configures a relational database function.

public static IConventionDbFunctionBuilder HasDbFunction(this IConventionModelBuilder modelBuilder, MethodInfo methodInfo, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

methodInfo MethodInfo

The method this function uses.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionDbFunctionBuilder

A builder to further configure the function.

HasDbFunction(IConventionModelBuilder, string, Type, bool)

Configures a relational database function.

public static IConventionDbFunctionBuilder HasDbFunction(this IConventionModelBuilder modelBuilder, string name, Type returnType, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

name string

The name of the function.

returnType Type

The function's return type.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionDbFunctionBuilder

A builder to further configure the function.

HasDbFunction(ModelBuilder, MethodInfo)

Configures a database function when targeting a relational database.

public static DbFunctionBuilder HasDbFunction(this ModelBuilder modelBuilder, MethodInfo methodInfo)

Parameters

modelBuilder ModelBuilder

The model builder.

methodInfo MethodInfo

The methodInfo this dbFunction uses.

Returns

DbFunctionBuilder

A builder to further configure the function.

HasDbFunction(ModelBuilder, MethodInfo, Action<DbFunctionBuilder>)

Configures a database function when targeting a relational database.

public static ModelBuilder HasDbFunction(this ModelBuilder modelBuilder, MethodInfo methodInfo, Action<DbFunctionBuilder> builderAction)

Parameters

modelBuilder ModelBuilder

The model builder.

methodInfo MethodInfo

The methodInfo this dbFunction uses.

builderAction Action<DbFunctionBuilder>

An action that performs configuration of the sequence.

Returns

ModelBuilder

A builder to further configure the function.

HasDbFunction<TResult>(ModelBuilder, Expression<Func<TResult>>)

Configures a database function when targeting a relational database.

public static DbFunctionBuilder HasDbFunction<TResult>(this ModelBuilder modelBuilder, Expression<Func<TResult>> expression)

Parameters

modelBuilder ModelBuilder

The model builder.

expression Expression<Func<TResult>>

The method this dbFunction uses.

Returns

DbFunctionBuilder

A builder to further configure the function.

Type Parameters

TResult

HasDefaultSchema(IConventionModelBuilder, string, bool)

Configures the default schema that database objects should be created in, if no schema is explicitly configured.

public static IConventionModelBuilder HasDefaultSchema(this IConventionModelBuilder modelBuilder, string schema, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

schema string

The default schema.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionModelBuilder

The same builder instance if the configuration was applied, null otherwise.

HasDefaultSchema(ModelBuilder, string)

Configures the default schema that database objects should be created in, if no schema is explicitly configured.

public static ModelBuilder HasDefaultSchema(this ModelBuilder modelBuilder, string schema)

Parameters

modelBuilder ModelBuilder

The model builder.

schema string

The default schema.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.

HasMaxIdentifierLength(IConventionModelBuilder, int?, bool)

Configures the maximum length allowed for store identifiers.

public static IConventionModelBuilder HasMaxIdentifierLength(this IConventionModelBuilder modelBuilder, int? length, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

length int?

The value to set.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionModelBuilder

The same builder instance if the configuration was applied, null otherwise.

HasSequence(IConventionModelBuilder, string, string, bool)

Configures a database sequence when targeting a relational database.

public static IConventionSequenceBuilder HasSequence(this IConventionModelBuilder modelBuilder, string name, string schema = null, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

name string

The name of the sequence.

schema string

The schema of the sequence.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionSequenceBuilder

A builder to further configure the sequence.

HasSequence(ModelBuilder, string, Action<SequenceBuilder>)

Configures a database sequence when targeting a relational database.

public static ModelBuilder HasSequence(this ModelBuilder modelBuilder, string name, Action<SequenceBuilder> builderAction)

Parameters

modelBuilder ModelBuilder

The model builder.

name string

The name of the sequence.

builderAction Action<SequenceBuilder>

An action that performs configuration of the sequence.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.

HasSequence(ModelBuilder, string, string)

Configures a database sequence when targeting a relational database.

public static SequenceBuilder HasSequence(this ModelBuilder modelBuilder, string name, string schema = null)

Parameters

modelBuilder ModelBuilder

The model builder.

name string

The name of the sequence.

schema string

The schema of the sequence.

Returns

SequenceBuilder

A builder to further configure the sequence.

HasSequence(ModelBuilder, string, string, Action<SequenceBuilder>)

Configures a database sequence when targeting a relational database.

public static ModelBuilder HasSequence(this ModelBuilder modelBuilder, string name, string schema, Action<SequenceBuilder> builderAction)

Parameters

modelBuilder ModelBuilder

The model builder.

name string

The name of the sequence.

schema string

The schema of the sequence.

builderAction Action<SequenceBuilder>

An action that performs configuration of the sequence.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.

HasSequence(ModelBuilder, Type, string, Action<SequenceBuilder>)

Configures a database sequence when targeting a relational database.

public static ModelBuilder HasSequence(this ModelBuilder modelBuilder, Type type, string name, Action<SequenceBuilder> builderAction)

Parameters

modelBuilder ModelBuilder

The model builder.

type Type

The type of values the sequence will generate.

name string

The name of the sequence.

builderAction Action<SequenceBuilder>

An action that performs configuration of the sequence.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.

HasSequence(ModelBuilder, Type, string, string)

Configures a database sequence when targeting a relational database.

public static SequenceBuilder HasSequence(this ModelBuilder modelBuilder, Type type, string name, string schema = null)

Parameters

modelBuilder ModelBuilder

The model builder.

type Type

The type of values the sequence will generate.

name string

The name of the sequence.

schema string

The schema of the sequence.

Returns

SequenceBuilder

A builder to further configure the sequence.

HasSequence(ModelBuilder, Type, string, string, Action<SequenceBuilder>)

Configures a database sequence when targeting a relational database.

public static ModelBuilder HasSequence(this ModelBuilder modelBuilder, Type type, string name, string schema, Action<SequenceBuilder> builderAction)

Parameters

modelBuilder ModelBuilder

The model builder.

type Type

The type of values the sequence will generate.

name string

The name of the sequence.

schema string

The schema of the sequence.

builderAction Action<SequenceBuilder>

An action that performs configuration of the sequence.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.

HasSequence<T>(ModelBuilder, string, Action<SequenceBuilder>)

Configures a database sequence when targeting a relational database.

public static ModelBuilder HasSequence<T>(this ModelBuilder modelBuilder, string name, Action<SequenceBuilder> builderAction)

Parameters

modelBuilder ModelBuilder

The model builder.

name string

The name of the sequence.

builderAction Action<SequenceBuilder>

An action that performs configuration of the sequence.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.

Type Parameters

T

The type of values the sequence will generate.

HasSequence<T>(ModelBuilder, string, string)

Configures a database sequence when targeting a relational database.

public static SequenceBuilder HasSequence<T>(this ModelBuilder modelBuilder, string name, string schema = null)

Parameters

modelBuilder ModelBuilder

The model builder.

name string

The name of the sequence.

schema string

The schema of the sequence.

Returns

SequenceBuilder

A builder to further configure the sequence.

Type Parameters

T

The type of values the sequence will generate.

HasSequence<T>(ModelBuilder, string, string, Action<SequenceBuilder>)

Configures a database sequence when targeting a relational database.

public static ModelBuilder HasSequence<T>(this ModelBuilder modelBuilder, string name, string schema, Action<SequenceBuilder> builderAction)

Parameters

modelBuilder ModelBuilder

The model builder.

name string

The name of the sequence.

schema string

The schema of the sequence.

builderAction Action<SequenceBuilder>

An action that performs configuration of the sequence.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.

Type Parameters

T

The type of values the sequence will generate.

UseCollation(IConventionModelBuilder, string, bool)

Configures the database collation, which will be used by all columns without an explicit collation.

public static IConventionModelBuilder UseCollation(this IConventionModelBuilder modelBuilder, string collation, bool fromDataAnnotation = false)

Parameters

modelBuilder IConventionModelBuilder

The model builder.

collation string

The collation.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionModelBuilder

The same builder instance if the configuration was applied, null otherwise.

UseCollation(ModelBuilder, string)

Configures the database collation, which will be used by all columns without an explicit collation.

public static ModelBuilder UseCollation(this ModelBuilder modelBuilder, string collation)

Parameters

modelBuilder ModelBuilder

The model builder.

collation string

The collation.

Returns

ModelBuilder

The same builder instance so that multiple calls can be chained.