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
modelIConventionModelThe model to add the function to.
methodInfoMethodInfoThe MethodInfo for the method that is mapped to the function.
fromDataAnnotationboolIndicates 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
modelIConventionModelThe model to add the function to.
namestringThe model name of the function.
returnTypeTypeThe function return type.
fromDataAnnotationboolIndicates 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
modelIMutableModelThe model to add the function to.
methodInfoMethodInfoThe 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
modelIMutableModelThe model to add the function to.
namestringThe model name of the function.
returnTypeTypeThe 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
modelIConventionModelThe model to add the sequence to.
namestringThe sequence name.
schemastringThe schema name, or null to use the default schema.
fromDataAnnotationboolIndicates 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
modelIMutableModelThe model to add the sequence to.
namestringThe sequence name.
schemastringThe 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
modelIConventionModelThe model to find the function in.
methodMethodInfoThe 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
modelIConventionModelThe model to find the function in.
namestringThe 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
modelIModelThe model to find the function in.
methodMethodInfoThe 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
modelIModelThe model to find the function in.
namestringThe 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
modelIMutableModelThe model to find the function in.
methodMethodInfoThe 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
modelIMutableModelThe model to find the function in.
namestringThe 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
modelIReadOnlyModelThe model to find the function in.
methodMethodInfoThe 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
modelIReadOnlyModelThe model to find the function in.
namestringThe 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
modelIConventionModelThe model to find the sequence in.
namestringThe sequence name.
schemastringThe 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
modelIModelThe model to find the sequence in.
namestringThe sequence name.
schemastringThe schema that contains the sequence.
Returns
FindSequence(IMutableModel, string, string?)
Finds a sequence with the given name.
public static IMutableSequence? FindSequence(this IMutableModel model, string name, string? schema = null)
Parameters
modelIMutableModelThe model to find the sequence in.
namestringThe sequence name.
schemastringThe 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
modelIReadOnlyModelThe model to find the sequence in.
namestringThe sequence name.
schemastringThe 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
modelIReadOnlyModelThe 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
modelIConventionModelThe 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
modelIConventionModelThe model to get the functions in.
Returns
GetDbFunctions(IModel)
Returns all functions contained in the model.
public static IEnumerable<IDbFunction> GetDbFunctions(this IModel model)
Parameters
modelIModelThe model to get the functions in.
Returns
GetDbFunctions(IMutableModel)
Returns all functions contained in the model.
public static IEnumerable<IMutableDbFunction> GetDbFunctions(this IMutableModel model)
Parameters
modelIMutableModelThe model to get the functions in.
Returns
GetDbFunctions(IReadOnlyModel)
Returns all functions contained in the model.
public static IEnumerable<IReadOnlyDbFunction> GetDbFunctions(this IReadOnlyModel model)
Parameters
modelIReadOnlyModelThe model to get the functions in.
Returns
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
modelIReadOnlyModelThe 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
modelIConventionModelThe 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
modelIReadOnlyModelThe 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
modelIConventionModelThe 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
modelIModelThe 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
modelIConventionModelThe model to get the sequences in.
Returns
GetSequences(IModel)
Returns all sequences contained in the model.
public static IEnumerable<ISequence> GetSequences(this IModel model)
Parameters
modelIModelThe model to get the sequences in.
Returns
GetSequences(IMutableModel)
Returns all sequences contained in the model.
public static IEnumerable<IMutableSequence> GetSequences(this IMutableModel model)
Parameters
modelIMutableModelThe model to get the sequences in.
Returns
GetSequences(IReadOnlyModel)
Returns all sequences contained in the model.
public static IEnumerable<IReadOnlySequence> GetSequences(this IReadOnlyModel model)
Parameters
modelIReadOnlyModelThe model to get the sequences in.
Returns
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
modelIConventionModelThe model to find the function in.
methodMethodInfoThe 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
modelIConventionModelThe model to find the function in.
namestringThe 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
modelIMutableModelThe model to find the function in.
methodMethodInfoThe 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
modelIMutableModelThe model to find the function in.
namestringThe 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
modelIConventionModelThe model to find the sequence in.
namestringThe sequence name.
schemastringThe 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
modelIMutableModelThe model to find the sequence in.
namestringThe sequence name.
schemastringThe 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
modelIConventionModelThe model to set the collation for.
valuestringThe value to set.
fromDataAnnotationboolIndicates 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
modelIMutableModelThe model to set the collation for.
valuestringThe value to set.
SetDefaultSchema(IConventionModel, string?, bool)
Sets the default schema.
public static string? SetDefaultSchema(this IConventionModel model, string? value, bool fromDataAnnotation = false)
Parameters
modelIConventionModelThe model to set the default schema for.
valuestringThe value to set.
fromDataAnnotationboolIndicates 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
modelIMutableModelThe model to set the default schema for.
valuestringThe 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
modelIConventionModelThe model to set the default schema for.
lengthint?The value to set.
fromDataAnnotationboolIndicates 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
modelIMutableModelThe model to set the default schema for.
lengthint?The value to set.