Table of Contents

Class RelationalModelExtensions

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

Relational-specific extension methods for Microsoft.EntityFrameworkCore.Metadata.IModel and extension methods for IRelationalModel.

public static class RelationalModelExtensions
Inheritance
RelationalModelExtensions
Inherited Members

Methods

AddDbFunction(IConventionModel, MethodInfo, bool)

Creates an IConventionDbFunction 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 IConventionDbFunction.

AddDbFunction(IConventionModel, string, Type, bool)

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 IConventionDbFunction.

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 an IMutableDbFunction.

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 IMutableDbFunction.

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 IConventionDbFunction 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 IConventionDbFunction or null if the method is not mapped.

FindDbFunction(IConventionModel, string)

Finds an IConventionDbFunction 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 IConventionDbFunction or null if the method is not mapped.

FindDbFunction(IModel, MethodInfo)

Finds a IDbFunction 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 IDbFunction or null if the method is not mapped.

FindDbFunction(IModel, string)

Finds an IDbFunction 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 IDbFunction or null if the method is not mapped.

FindDbFunction(IMutableModel, MethodInfo)

Finds a IMutableDbFunction 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 IMutableDbFunction or null if the method is not mapped.

FindDbFunction(IMutableModel, string)

Finds an IMutableDbFunction 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 IMutableDbFunction or null if the method is not mapped.

FindSequence(IConventionModel, string, string)

Finds an IConventionSequence 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 IConventionSequence or null if no sequence with the given name in the given schema was found.

FindSequence(IModel, string, string)

Finds an ISequence 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 ISequence or null if no sequence with the given name in the given schema was found.

FindSequence(IMutableModel, string, string)

Finds an IMutableSequence 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 IMutableSequence or null if no sequence with the given name in the given schema was found.

GetCollation(IModel)

Returns the database collation.

public static string GetCollation(this IModel model)

Parameters

model IModel

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 IConventionDbFunctions 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 IDbFunctions 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 IMutableDbFunctions 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>

GetDefaultSchema(IModel)

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

public static string GetDefaultSchema(this IModel model)

Parameters

model IModel

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(IModel)

Returns the maximum length allowed for store identifiers.

public static int GetMaxIdentifierLength(this IModel model)

Parameters

model IModel

The model to get the maximum identifier length for.

Returns

int

The maximum identifier length.

GetMaxIdentifierLengthConfigurationSource(IConventionModel)

Returns the configuration source for GetMaxIdentifierLength(IModel).

public static ConfigurationSource? GetMaxIdentifierLengthConfigurationSource(this IConventionModel model)

Parameters

model IConventionModel

The model to find configuration source for.

Returns

ConfigurationSource?

The configuration source for GetMaxIdentifierLength(IModel).

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 IConventionSequences 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 ISequences 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 IMutableSequences 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>

RemoveDbFunction(IConventionModel, MethodInfo)

Removes the IConventionDbFunction 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 IConventionDbFunction or null if the method is not mapped.

RemoveDbFunction(IConventionModel, string)

Removes the IConventionDbFunction 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 IConventionDbFunction or null if the method is not mapped.

RemoveDbFunction(IMutableModel, MethodInfo)

Removes the IMutableDbFunction 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 IMutableDbFunction or null if the method is not mapped.

RemoveDbFunction(IMutableModel, string)

Removes the IMutableDbFunction 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 IMutableDbFunction 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.

ToDebugString(IRelationalModel, MetadataDebugStringOptions, int)

Creates a human-readable representation of the given metadata.

Warning: Do not rely on the format of the returned string. It is designed for debugging only and may change arbitrarily between releases.

public static string ToDebugString(this IRelationalModel model, MetadataDebugStringOptions options, int indent = 0)

Parameters

model IRelationalModel

The metadata item.

options MetadataDebugStringOptions

Options for generating the string.

indent int

The number of indent spaces to use before each new line.

Returns

string

A human-readable representation.