Class NpgsqlModelExtensions
- Namespace
- Microsoft.EntityFrameworkCore
- Assembly
- Npgsql.EntityFrameworkCore.PostgreSQL.dll
Model extension methods for Npgsql-specific metadata.
public static class NpgsqlModelExtensions
- Inheritance
-
NpgsqlModelExtensions
- Inherited Members
Remarks
Fields
DefaultHiLoSequenceName
The default name for the hi-lo sequence.
public const string DefaultHiLoSequenceName = "EntityFrameworkHiLoSequence"
Field Value
DefaultSequenceNameSuffix
The default prefix for sequences applied to properties.
public const string DefaultSequenceNameSuffix = "Sequence"
Field Value
Methods
GetCollations(IReadOnlyModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static IReadOnlyList<PostgresCollation> GetCollations(this IReadOnlyModel model)
Parameters
modelIReadOnlyModel
Returns
GetDatabaseTemplate(IReadOnlyModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static string? GetDatabaseTemplate(this IReadOnlyModel model)
Parameters
modelIReadOnlyModel
Returns
GetDatabaseTemplateConfigurationSource(IConventionModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static ConfigurationSource? GetDatabaseTemplateConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModel
Returns
GetDefaultColumnCollation(IReadOnlyModel)
Gets the default collation for all columns in the database, or null if none is defined. This causes EF Core to specify an explicit collation when creating all column, unless one is overridden on a column.
[Obsolete("Use EF Core's standard model bulk configuration API")]
public static string? GetDefaultColumnCollation(this IReadOnlyModel model)
Parameters
modelIReadOnlyModel
Returns
Remarks
See GetCollation(IReadOnlyModel) for another approach to defining a database-wide collation.
For more information, see https://www.postgresql.org/docs/current/collation.html.
GetDefaultColumnCollationConfigurationSource(IConventionModel)
Returns the ConfigurationSource for the default column collation.
[Obsolete("Use EF Core's standard model bulk configuration API")]
public static ConfigurationSource? GetDefaultColumnCollationConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModelThe model.
Returns
- ConfigurationSource?
The ConfigurationSource for the default column collation.
GetHiLoSequenceName(IReadOnlyModel)
Returns the name to use for the default hi-lo sequence.
public static string GetHiLoSequenceName(this IReadOnlyModel model)
Parameters
modelIReadOnlyModelThe model.
Returns
- string
The name to use for the default hi-lo sequence.
GetHiLoSequenceNameConfigurationSource(IConventionModel)
Returns the ConfigurationSource for the default hi-lo sequence name.
public static ConfigurationSource? GetHiLoSequenceNameConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModelThe model.
Returns
- ConfigurationSource?
The ConfigurationSource for the default hi-lo sequence name.
GetHiLoSequenceSchema(IReadOnlyModel)
Returns the schema to use for the default hi-lo sequence. UseHiLo(PropertyBuilder, string?, string?)
public static string? GetHiLoSequenceSchema(this IReadOnlyModel model)
Parameters
modelIReadOnlyModelThe model.
Returns
- string
The schema to use for the default hi-lo sequence.
GetHiLoSequenceSchemaConfigurationSource(IConventionModel)
Returns the ConfigurationSource for the default hi-lo sequence schema.
public static ConfigurationSource? GetHiLoSequenceSchemaConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModelThe model.
Returns
- ConfigurationSource?
The ConfigurationSource for the default hi-lo sequence schema.
GetOrAddCollation(IMutableModel, string?, string, string, string, string?, bool?)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static PostgresCollation GetOrAddCollation(this IMutableModel model, string? schema, string name, string lcCollate, string lcCtype, string? provider = null, bool? deterministic = null)
Parameters
modelIMutableModelschemastringnamestringlcCollatestringlcCtypestringproviderstringdeterministicbool?
Returns
GetOrAddPostgresEnum(IMutableModel, string?, string, string[])
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static PostgresEnum GetOrAddPostgresEnum(this IMutableModel model, string? schema, string name, string[] labels)
Parameters
modelIMutableModelschemastringnamestringlabelsstring[]
Returns
GetOrAddPostgresExtension(IConventionModel, string?, string, string?)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static PostgresExtension GetOrAddPostgresExtension(this IConventionModel model, string? schema, string name, string? version)
Parameters
modelIConventionModelschemastringnamestringversionstring
Returns
GetOrAddPostgresExtension(IMutableModel, string?, string, string?)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static PostgresExtension GetOrAddPostgresExtension(this IMutableModel model, string? schema, string name, string? version)
Parameters
modelIMutableModelschemastringnamestringversionstring
Returns
GetOrAddPostgresRange(IMutableModel, string?, string, string, string?, string?, string?, string?)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static PostgresRange GetOrAddPostgresRange(this IMutableModel model, string? schema, string name, string subtype, string? canonicalFunction = null, string? subtypeOpClass = null, string? collation = null, string? subtypeDiff = null)
Parameters
modelIMutableModelschemastringnamestringsubtypestringcanonicalFunctionstringsubtypeOpClassstringcollationstringsubtypeDiffstring
Returns
GetPostgresEnums(IReadOnlyModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static IReadOnlyList<PostgresEnum> GetPostgresEnums(this IReadOnlyModel model)
Parameters
modelIReadOnlyModel
Returns
GetPostgresExtensions(IReadOnlyModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static IReadOnlyList<PostgresExtension> GetPostgresExtensions(this IReadOnlyModel model)
Parameters
modelIReadOnlyModel
Returns
GetSequenceNameSuffix(IReadOnlyModel)
Returns the suffix to append to the name of automatically created sequences.
public static string GetSequenceNameSuffix(this IReadOnlyModel model)
Parameters
modelIReadOnlyModelThe model.
Returns
- string
The name to use for the default key value generation sequence.
GetSequenceNameSuffixConfigurationSource(IConventionModel)
Returns the ConfigurationSource for the default value generation sequence name suffix.
public static ConfigurationSource? GetSequenceNameSuffixConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModelThe model.
Returns
- ConfigurationSource?
The ConfigurationSource for the default key value generation sequence name.
GetSequenceSchema(IReadOnlyModel)
Returns the schema to use for the default value generation sequence. UseSequence(PropertyBuilder, string?, string?)
public static string? GetSequenceSchema(this IReadOnlyModel model)
Parameters
modelIReadOnlyModelThe model.
Returns
- string
The schema to use for the default key value generation sequence.
GetSequenceSchemaConfigurationSource(IConventionModel)
Returns the ConfigurationSource for the default key value generation sequence schema.
public static ConfigurationSource? GetSequenceSchemaConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModelThe model.
Returns
- ConfigurationSource?
The ConfigurationSource for the default key value generation sequence schema.
GetTablespace(IReadOnlyModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static string? GetTablespace(this IReadOnlyModel model)
Parameters
modelIReadOnlyModel
Returns
GetTablespaceConfigurationSource(IConventionModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static ConfigurationSource? GetTablespaceConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModel
Returns
GetValueGenerationStrategy(IReadOnlyModel)
Returns the NpgsqlValueGenerationStrategy to use for properties of keys in the model, unless the property has a strategy explicitly set.
public static NpgsqlValueGenerationStrategy? GetValueGenerationStrategy(this IReadOnlyModel model)
Parameters
modelIReadOnlyModelThe model.
Returns
- NpgsqlValueGenerationStrategy?
The default NpgsqlValueGenerationStrategy.
GetValueGenerationStrategyConfigurationSource(IConventionModel)
Returns the ConfigurationSource for the default NpgsqlValueGenerationStrategy.
public static ConfigurationSource? GetValueGenerationStrategyConfigurationSource(this IConventionModel model)
Parameters
modelIConventionModelThe model.
Returns
- ConfigurationSource?
The ConfigurationSource for the default NpgsqlValueGenerationStrategy.
PostgresRanges(IReadOnlyModel)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static IReadOnlyList<PostgresRange> PostgresRanges(this IReadOnlyModel model)
Parameters
modelIReadOnlyModel
Returns
SetDatabaseTemplate(IConventionModel, string?, bool)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static string? SetDatabaseTemplate(this IConventionModel model, string? template, bool fromDataAnnotation = false)
Parameters
modelIConventionModeltemplatestringfromDataAnnotationbool
Returns
SetDatabaseTemplate(IMutableModel, string?)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static void SetDatabaseTemplate(this IMutableModel model, string? template)
Parameters
modelIMutableModeltemplatestring
SetDefaultColumnCollation(IConventionModel, string?, bool)
Sets the default collation for all columns in the database, or null if none is defined.
This causes EF Core to specify an explicit collation when creating all column, unless one is overridden
on a column.
[Obsolete("Use EF Core's standard model bulk configuration API")]
public static string? SetDefaultColumnCollation(this IConventionModel model, string? collation, bool fromDataAnnotation = false)
Parameters
modelIConventionModelcollationstringfromDataAnnotationbool
Returns
Remarks
See SetCollation(IMutableModel, string) for another approach to defining a database-wide collation.
For more information, see https://www.postgresql.org/docs/current/collation.html.
SetDefaultColumnCollation(IMutableModel, string?)
Sets the default collation for all columns in the database, or null if none is defined.
This causes EF Core to specify an explicit collation when creating all column, unless one is overridden
on a column.
[Obsolete("Use EF Core's standard model bulk configuration API")]
public static void SetDefaultColumnCollation(this IMutableModel model, string? collation)
Parameters
modelIMutableModelcollationstring
Remarks
See GetCollation(IReadOnlyModel) for another approach to defining a database-wide collation.
For more information, see https://www.postgresql.org/docs/current/collation.html.
SetHiLoSequenceName(IConventionModel, string?, bool)
Sets the name to use for the default hi-lo sequence.
public static string? SetHiLoSequenceName(this IConventionModel model, string? name, bool fromDataAnnotation = false)
Parameters
modelIConventionModelThe model.
namestringThe value to set.
fromDataAnnotationboolIndicates whether the configuration was specified using a data annotation.
Returns
SetHiLoSequenceName(IMutableModel, string?)
Sets the name to use for the default hi-lo sequence.
public static void SetHiLoSequenceName(this IMutableModel model, string? name)
Parameters
modelIMutableModelThe model.
namestringThe value to set.
SetHiLoSequenceSchema(IConventionModel, string?, bool)
Sets the schema to use for the default hi-lo sequence.
public static string? SetHiLoSequenceSchema(this IConventionModel model, string? value, bool fromDataAnnotation = false)
Parameters
modelIConventionModelThe model.
valuestringThe value to set.
fromDataAnnotationboolIndicates whether the configuration was specified using a data annotation.
Returns
SetHiLoSequenceSchema(IMutableModel, string?)
Sets the schema to use for the default hi-lo sequence.
public static void SetHiLoSequenceSchema(this IMutableModel model, string? value)
Parameters
modelIMutableModelThe model.
valuestringThe value to set.
SetSequenceNameSuffix(IConventionModel, string?, bool)
Sets the suffix to append to the name of automatically created sequences.
public static string? SetSequenceNameSuffix(this IConventionModel model, string? name, bool fromDataAnnotation = false)
Parameters
modelIConventionModelThe model.
namestringThe value to set.
fromDataAnnotationboolIndicates whether the configuration was specified using a data annotation.
Returns
- string
The configured value.
SetSequenceNameSuffix(IMutableModel, string?)
Sets the suffix to append to the name of automatically created sequences.
public static void SetSequenceNameSuffix(this IMutableModel model, string? name)
Parameters
modelIMutableModelThe model.
namestringThe value to set.
SetSequenceSchema(IConventionModel, string?, bool)
Sets the schema to use for the default key value generation sequence.
public static string? SetSequenceSchema(this IConventionModel model, string? value, bool fromDataAnnotation = false)
Parameters
modelIConventionModelThe model.
valuestringThe value to set.
fromDataAnnotationboolIndicates whether the configuration was specified using a data annotation.
Returns
- string
The configured value.
SetSequenceSchema(IMutableModel, string?)
Sets the schema to use for the default key value generation sequence.
public static void SetSequenceSchema(this IMutableModel model, string? value)
Parameters
modelIMutableModelThe model.
valuestringThe value to set.
SetTablespace(IConventionModel, string?, bool)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static string? SetTablespace(this IConventionModel model, string? tablespace, bool fromDataAnnotation = false)
Parameters
modelIConventionModeltablespacestringfromDataAnnotationbool
Returns
SetTablespace(IMutableModel, string?)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
public static void SetTablespace(this IMutableModel model, string? tablespace)
Parameters
modelIMutableModeltablespacestring
SetValueGenerationStrategy(IConventionModel, NpgsqlValueGenerationStrategy?, bool)
Attempts to set the NpgsqlValueGenerationStrategy to use for properties of keys in the model that don't have a strategy explicitly set.
public static NpgsqlValueGenerationStrategy? SetValueGenerationStrategy(this IConventionModel model, NpgsqlValueGenerationStrategy? value, bool fromDataAnnotation = false)
Parameters
modelIConventionModelThe model.
valueNpgsqlValueGenerationStrategy?The value to set.
fromDataAnnotationboolIndicates whether the configuration was specified using a data annotation.
Returns
SetValueGenerationStrategy(IMutableModel, NpgsqlValueGenerationStrategy?)
Attempts to set the NpgsqlValueGenerationStrategy to use for properties of keys in the model that don't have a strategy explicitly set.
public static void SetValueGenerationStrategy(this IMutableModel model, NpgsqlValueGenerationStrategy? value)
Parameters
modelIMutableModelThe model.
valueNpgsqlValueGenerationStrategy?The value to set.