Table of Contents

Class RelationalModelExtensions

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

Relational-specific model extension methods.

public static class RelationalModelExtensions
Inheritance
RelationalModelExtensions
Inherited Members

Remarks

See Modeling entity types and relationships for more information and examples.

Methods

AddDbFunction(IConventionModel, MethodInfo, bool)

Creates a function mapped to the given method.

public static IConventionDbFunction AddDbFunction(this IConventionModel model, MethodInfo methodInfo, bool fromDataAnnotation = false)

Parameters

model IConventionModel

The model to add the function to.

methodInfo MethodInfo

The MethodInfo for the method that is mapped to the function.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionDbFunction

The new function.

AddDbFunction(IConventionModel, string, Type, bool)

Creates a function.

public static IConventionDbFunction AddDbFunction(this IConventionModel model, string name, Type returnType, bool fromDataAnnotation = false)

Parameters

model IConventionModel

The model to add the function to.

name string

The model name of the function.

returnType Type

The function return type.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionDbFunction

The new function.

AddDbFunction(IMutableModel, MethodInfo)

Creates an IMutableDbFunction mapped to the given method.

public static IMutableDbFunction AddDbFunction(this IMutableModel model, MethodInfo methodInfo)

Parameters

model IMutableModel

The model to add the function to.

methodInfo MethodInfo

The MethodInfo for the method that is mapped to the function.

Returns

IMutableDbFunction

The new IMutableDbFunction.

AddDbFunction(IMutableModel, string, Type)

Creates a function.

public static IMutableDbFunction AddDbFunction(this IMutableModel model, string name, Type returnType)

Parameters

model IMutableModel

The model to add the function to.

name string

The model name of the function.

returnType Type

The function return type.

Returns

IMutableDbFunction

The new function.

AddSequence(IConventionModel, string, string?, bool)

Either returns the existing IMutableSequence with the given name in the given schema or creates a new sequence with the given name and schema.

public static IConventionSequence? AddSequence(this IConventionModel model, string name, string? schema = null, bool fromDataAnnotation = false)

Parameters

model IConventionModel

The model to add the sequence to.

name string

The sequence name.

schema string

The schema name, or null to use the default schema.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

IConventionSequence

The sequence.

AddSequence(IMutableModel, string, string?)

Either returns the existing IMutableSequence with the given name in the given schema or creates a new sequence with the given name and schema.

public static IMutableSequence AddSequence(this IMutableModel model, string name, string? schema = null)

Parameters

model IMutableModel

The model to add the sequence to.

name string

The sequence name.

schema string

The schema name, or null to use the default schema.

Returns

IMutableSequence

The sequence.

FindDbFunction(IConventionModel, MethodInfo)

Finds a function that is mapped to the method represented by the given MethodInfo.

public static IConventionDbFunction? FindDbFunction(this IConventionModel model, MethodInfo method)

Parameters

model IConventionModel

The model to find the function in.

method MethodInfo

The MethodInfo for the method that is mapped to the function.

Returns

IConventionDbFunction

The function or null if the method is not mapped.

FindDbFunction(IConventionModel, string)

Finds a function that is mapped to the method represented by the given name.

public static IConventionDbFunction? FindDbFunction(this IConventionModel model, string name)

Parameters

model IConventionModel

The model to find the function in.

name string

The model name of the function.

Returns

IConventionDbFunction

The function or null if the method is not mapped.

FindDbFunction(IModel, MethodInfo)

Finds a function that is mapped to the method represented by the given MethodInfo.

public static IDbFunction? FindDbFunction(this IModel model, MethodInfo method)

Parameters

model IModel

The model to find the function in.

method MethodInfo

The MethodInfo for the method that is mapped to the function.

Returns

IDbFunction

The function or null if the method is not mapped.

FindDbFunction(IModel, string)

Finds a function that is mapped to the method represented by the given name.

public static IDbFunction? FindDbFunction(this IModel model, string name)

Parameters

model IModel

The model to find the function in.

name string

The model name of the function.

Returns

IDbFunction

The function or null if the method is not mapped.

FindDbFunction(IMutableModel, MethodInfo)

Finds a function that is mapped to the method represented by the given MethodInfo.

public static IMutableDbFunction? FindDbFunction(this IMutableModel model, MethodInfo method)

Parameters

model IMutableModel

The model to find the function in.

method MethodInfo

The MethodInfo for the method that is mapped to the function.

Returns

IMutableDbFunction

The function or null if the method is not mapped.

FindDbFunction(IMutableModel, string)

Finds a function that is mapped to the method represented by the given name.

public static IMutableDbFunction? FindDbFunction(this IMutableModel model, string name)

Parameters

model IMutableModel

The model to find the function in.

name string

The model name of the function.

Returns

IMutableDbFunction

The function or null if the method is not mapped.

FindDbFunction(IReadOnlyModel, MethodInfo)

Finds a function that is mapped to the method represented by the given MethodInfo.

public static IReadOnlyDbFunction? FindDbFunction(this IReadOnlyModel model, MethodInfo method)

Parameters

model IReadOnlyModel

The model to find the function in.

method MethodInfo

The MethodInfo for the method that is mapped to the function.

Returns

IReadOnlyDbFunction

The function or null if the method is not mapped.

FindDbFunction(IReadOnlyModel, string)

Finds a function that is mapped to the method represented by the given name.

public static IReadOnlyDbFunction? FindDbFunction(this IReadOnlyModel model, string name)

Parameters

model IReadOnlyModel

The model to find the function in.

name string

The model name of the function.

Returns

IReadOnlyDbFunction

The function or null if the method is not mapped.

FindSequence(IConventionModel, string, string?)

Finds a sequence with the given name.

public static IConventionSequence? FindSequence(this IConventionModel model, string name, string? schema = null)

Parameters

model IConventionModel

The model to find the sequence in.

name string

The sequence name.

schema string

The schema that contains the sequence.

Returns

IConventionSequence

The sequence or null if no sequence with the given name in the given schema was found.

FindSequence(IModel, string, string?)

Finds a sequence with the given name.

public static ISequence? FindSequence(this IModel model, string name, string? schema = null)

Parameters

model IModel

The model to find the sequence in.

name string

The sequence name.

schema string

The schema that contains the sequence.

Returns

ISequence

The sequence or null if no sequence with the given name in the given schema was found.

FindSequence(IMutableModel, string, string?)

Finds a sequence with the given name.

public static IMutableSequence? FindSequence(this IMutableModel model, string name, string? schema = null)

Parameters

model IMutableModel

The model to find the sequence in.

name string

The sequence name.

schema string

The schema that contains the sequence.

Returns

IMutableSequence

The sequence or null if no sequence with the given name in the given schema was found.

FindSequence(IReadOnlyModel, string, string?)

Finds a sequence with the given name.

public static IReadOnlySequence? FindSequence(this IReadOnlyModel model, string name, string? schema = null)

Parameters

model IReadOnlyModel

The model to find the sequence in.

name string

The sequence name.

schema string

The schema that contains the sequence.

Returns

IReadOnlySequence

The sequence or null if no sequence with the given name in the given schema was found.

GetCollation(IReadOnlyModel)

Returns the database collation.

public static string? GetCollation(this IReadOnlyModel model)

Parameters

model IReadOnlyModel

The model to get the collation for.

Returns

string

The collation.

GetCollationConfigurationSource(IConventionModel)

Returns the configuration source for the collation.

public static ConfigurationSource? GetCollationConfigurationSource(this IConventionModel model)

Parameters

model IConventionModel

The model to find configuration source for.

Returns

ConfigurationSource?

The configuration source for the collation.

GetDbFunctions(IConventionModel)

Returns all functions contained in the model.

public static IEnumerable<IConventionDbFunction> GetDbFunctions(this IConventionModel model)

Parameters

model IConventionModel

The model to get the functions in.

Returns

IEnumerable<IConventionDbFunction>

GetDbFunctions(IModel)

Returns all functions contained in the model.

public static IEnumerable<IDbFunction> GetDbFunctions(this IModel model)

Parameters

model IModel

The model to get the functions in.

Returns

IEnumerable<IDbFunction>

GetDbFunctions(IMutableModel)

Returns all functions contained in the model.

public static IEnumerable<IMutableDbFunction> GetDbFunctions(this IMutableModel model)

Parameters

model IMutableModel

The model to get the functions in.

Returns

IEnumerable<IMutableDbFunction>

GetDbFunctions(IReadOnlyModel)

Returns all functions contained in the model.

public static IEnumerable<IReadOnlyDbFunction> GetDbFunctions(this IReadOnlyModel model)

Parameters

model IReadOnlyModel

The model to get the functions in.

Returns

IEnumerable<IReadOnlyDbFunction>

GetDefaultSchema(IReadOnlyModel)

Returns the default schema to use for the model, or null if none has been set.

public static string? GetDefaultSchema(this IReadOnlyModel model)

Parameters

model IReadOnlyModel

The model to get the default schema for.

Returns

string

The default schema.

GetDefaultSchemaConfigurationSource(IConventionModel)

Returns the configuration source for the default schema.

public static ConfigurationSource? GetDefaultSchemaConfigurationSource(this IConventionModel model)

Parameters

model IConventionModel

The model to find configuration source for.

Returns

ConfigurationSource?

The configuration source for the default schema.

GetMaxIdentifierLength(IReadOnlyModel)

Returns the maximum length allowed for store identifiers.

public static int GetMaxIdentifierLength(this IReadOnlyModel model)

Parameters

model IReadOnlyModel

The model to get the maximum identifier length for.

Returns

int

The maximum identifier length.

GetMaxIdentifierLengthConfigurationSource(IConventionModel)

Returns the configuration source for GetMaxIdentifierLength(IReadOnlyModel).

public static ConfigurationSource? GetMaxIdentifierLengthConfigurationSource(this IConventionModel model)

Parameters

model IConventionModel

The model to find configuration source for.

Returns

ConfigurationSource?

The configuration source for GetMaxIdentifierLength(IReadOnlyModel).

GetRelationalModel(IModel)

Returns the database model.

public static IRelationalModel GetRelationalModel(this IModel model)

Parameters

model IModel

The model to get the database model for.

Returns

IRelationalModel

The database model.

GetSequences(IConventionModel)

Returns all sequences contained in the model.

public static IEnumerable<IConventionSequence> GetSequences(this IConventionModel model)

Parameters

model IConventionModel

The model to get the sequences in.

Returns

IEnumerable<IConventionSequence>

GetSequences(IModel)

Returns all sequences contained in the model.

public static IEnumerable<ISequence> GetSequences(this IModel model)

Parameters

model IModel

The model to get the sequences in.

Returns

IEnumerable<ISequence>

GetSequences(IMutableModel)

Returns all sequences contained in the model.

public static IEnumerable<IMutableSequence> GetSequences(this IMutableModel model)

Parameters

model IMutableModel

The model to get the sequences in.

Returns

IEnumerable<IMutableSequence>

GetSequences(IReadOnlyModel)

Returns all sequences contained in the model.

public static IEnumerable<IReadOnlySequence> GetSequences(this IReadOnlyModel model)

Parameters

model IReadOnlyModel

The model to get the sequences in.

Returns

IEnumerable<IReadOnlySequence>

RemoveDbFunction(IConventionModel, MethodInfo)

Removes the function that is mapped to the method represented by the given MethodInfo.

public static IConventionDbFunction? RemoveDbFunction(this IConventionModel model, MethodInfo method)

Parameters

model IConventionModel

The model to find the function in.

method MethodInfo

The MethodInfo for the method that is mapped to the function.

Returns

IConventionDbFunction

The removed function or null if the method is not mapped.

RemoveDbFunction(IConventionModel, string)

Removes the function that is mapped to the method represented by the given MethodInfo.

public static IConventionDbFunction? RemoveDbFunction(this IConventionModel model, string name)

Parameters

model IConventionModel

The model to find the function in.

name string

The model name of the function.

Returns

IConventionDbFunction

The removed function or null if the method is not mapped.

RemoveDbFunction(IMutableModel, MethodInfo)

Removes the function that is mapped to the method represented by the given MethodInfo.

public static IMutableDbFunction? RemoveDbFunction(this IMutableModel model, MethodInfo method)

Parameters

model IMutableModel

The model to find the function in.

method MethodInfo

The MethodInfo for the method that is mapped to the function.

Returns

IMutableDbFunction

The removed function or null if the method is not mapped.

RemoveDbFunction(IMutableModel, string)

Removes the function that is mapped to the method represented by the given MethodInfo.

public static IMutableDbFunction? RemoveDbFunction(this IMutableModel model, string name)

Parameters

model IMutableModel

The model to find the function in.

name string

The model name of the function.

Returns

IMutableDbFunction

The removed function or null if the method is not mapped.

RemoveSequence(IConventionModel, string, string?)

Removes the IConventionSequence with the given name.

public static IConventionSequence? RemoveSequence(this IConventionModel model, string name, string? schema = null)

Parameters

model IConventionModel

The model to find the sequence in.

name string

The sequence name.

schema string

The schema that contains the sequence.

Returns

IConventionSequence

The removed IConventionSequence or null if no sequence with the given name in the given schema was found.

RemoveSequence(IMutableModel, string, string?)

Removes the IMutableSequence with the given name.

public static IMutableSequence? RemoveSequence(this IMutableModel model, string name, string? schema = null)

Parameters

model IMutableModel

The model to find the sequence in.

name string

The sequence name.

schema string

The schema that contains the sequence.

Returns

IMutableSequence

The removed IMutableSequence or null if no sequence with the given name in the given schema was found.

SetCollation(IConventionModel, string?, bool)

Sets the database collation.

public static string? SetCollation(this IConventionModel model, string? value, bool fromDataAnnotation = false)

Parameters

model IConventionModel

The model to set the collation for.

value string

The value to set.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

string

The configured collation.

SetCollation(IMutableModel, string?)

Sets the database collation.

public static void SetCollation(this IMutableModel model, string? value)

Parameters

model IMutableModel

The model to set the collation for.

value string

The value to set.

SetDefaultSchema(IConventionModel, string?, bool)

Sets the default schema.

public static string? SetDefaultSchema(this IConventionModel model, string? value, bool fromDataAnnotation = false)

Parameters

model IConventionModel

The model to set the default schema for.

value string

The value to set.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

string

The configured schema.

SetDefaultSchema(IMutableModel, string?)

Sets the default schema.

public static void SetDefaultSchema(this IMutableModel model, string? value)

Parameters

model IMutableModel

The model to set the default schema for.

value string

The value to set.

SetMaxIdentifierLength(IConventionModel, int?, bool)

Sets the maximum length allowed for store identifiers.

public static int? SetMaxIdentifierLength(this IConventionModel model, int? length, bool fromDataAnnotation = false)

Parameters

model IConventionModel

The model to set the default schema for.

length int?

The value to set.

fromDataAnnotation bool

Indicates whether the configuration was specified using a data annotation.

Returns

int?

The configured value.

SetMaxIdentifierLength(IMutableModel, int?)

Sets the maximum length allowed for store identifiers.

public static void SetMaxIdentifierLength(this IMutableModel model, int? length)

Parameters

model IMutableModel

The model to set the default schema for.

length int?

The value to set.