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
Remarks
See Modeling entity types and relationships for more information and examples.
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
IConventionModelBuilderThe model builder.
collation
stringThe collation.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
Remarks
See Database collations for more information and examples.
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
IConventionModelBuilderThe model builder.
schema
stringThe default schema.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
Remarks
See Modeling entity types and relationships for more information and examples.
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
IConventionModelBuilderThe model builder.
length
int?The value to set.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
Remarks
See Modeling entity types and relationships for more information and examples.
HasDbFunction(IConventionModelBuilder, MethodInfo, bool)
Configures a relational database function.
public static IConventionDbFunctionBuilder HasDbFunction(this IConventionModelBuilder modelBuilder, MethodInfo methodInfo, bool fromDataAnnotation = false)
Parameters
modelBuilder
IConventionModelBuilderThe model builder.
methodInfo
MethodInfoThe method this function uses.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
- IConventionDbFunctionBuilder
A builder to further configure the function.
Remarks
See Database functions for more information and examples.
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
IConventionModelBuilderThe model builder.
name
stringThe name of the function.
returnType
TypeThe function's return type.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
- IConventionDbFunctionBuilder
A builder to further configure the function.
Remarks
See Database functions for more information and examples.
HasDbFunction(ModelBuilder, MethodInfo)
Configures a database function when targeting a relational database.
public static DbFunctionBuilder HasDbFunction(this ModelBuilder modelBuilder, MethodInfo methodInfo)
Parameters
modelBuilder
ModelBuilderThe model builder.
methodInfo
MethodInfoThe methodInfo this dbFunction uses.
Returns
- DbFunctionBuilder
A builder to further configure the function.
Remarks
See Database functions for more information and examples.
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
ModelBuilderThe model builder.
methodInfo
MethodInfoThe methodInfo this dbFunction uses.
builderAction
Action<DbFunctionBuilder>An action that performs configuration of the sequence.
Returns
- ModelBuilder
A builder to further configure the function.
Remarks
See Database functions for more information and examples.
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
ModelBuilderThe model builder.
expression
Expression<Func<TResult>>The method this dbFunction uses.
Returns
- DbFunctionBuilder
A builder to further configure the function.
Type Parameters
TResult
Remarks
See Database functions for more information and examples.
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
IConventionModelBuilderThe model builder.
schema
stringThe default schema.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
- IConventionModelBuilder
The same builder instance if the configuration was applied, null otherwise.
Remarks
See Modeling entity types and relationships for more information and examples.
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
ModelBuilderThe model builder.
schema
stringThe default schema.
Returns
- ModelBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Modeling entity types and relationships for more information and examples.
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
IConventionModelBuilderThe model builder.
length
int?The value to set.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
- IConventionModelBuilder
The same builder instance if the configuration was applied, null otherwise.
Remarks
See Modeling entity types and relationships for more information and examples.
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
IConventionModelBuilderThe model builder.
name
stringThe name of the sequence.
schema
stringThe schema of the sequence.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
- IConventionSequenceBuilder
A builder to further configure the sequence.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
name
stringThe 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.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
name
stringThe name of the sequence.
schema
stringThe schema of the sequence.
Returns
- SequenceBuilder
A builder to further configure the sequence.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
name
stringThe name of the sequence.
schema
stringThe 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.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
type
TypeThe type of values the sequence will generate.
name
stringThe 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.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
type
TypeThe type of values the sequence will generate.
name
stringThe name of the sequence.
schema
stringThe schema of the sequence.
Returns
- SequenceBuilder
A builder to further configure the sequence.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
type
TypeThe type of values the sequence will generate.
name
stringThe name of the sequence.
schema
stringThe 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.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
name
stringThe 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.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
name
stringThe name of the sequence.
schema
stringThe schema of the sequence.
Returns
- SequenceBuilder
A builder to further configure the sequence.
Type Parameters
T
The type of values the sequence will generate.
Remarks
See Database sequences for more information and examples.
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
ModelBuilderThe model builder.
name
stringThe name of the sequence.
schema
stringThe 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.
Remarks
See Database sequences for more information and examples.
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
IConventionModelBuilderThe model builder.
collation
stringThe collation.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
- IConventionModelBuilder
The same builder instance if the configuration was applied, null otherwise.
Remarks
See Database collations for more information and examples.
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
ModelBuilderThe model builder.
collation
stringThe collation.
Returns
- ModelBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Database collations for more information and examples.