# Class NpgsqlModelExtensions

Namespace
  Microsoft.EntityFrameworkCore

Assembly
  Npgsql.EntityFrameworkCore.PostgreSQL.dll

Model extension methods for Npgsql-specific metadata.

    public static class NpgsqlModelExtensions

Inheritance
  object
  NpgsqlModelExtensions

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

## Remarks

See Modeling entity types and relationships.

## Fields

### DefaultHiLoSequenceName

The default name for the hi-lo sequence.

    public const string DefaultHiLoSequenceName = "EntityFrameworkHiLoSequence"

#### Field Value

string

### DefaultSequenceNameSuffix

The default prefix for sequences applied to properties.

    public const string DefaultSequenceNameSuffix = "Sequence"

#### Field Value

string

## 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

`model` IReadOnlyModel

#### Returns

IReadOnlyList<PostgresCollation>

### 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

`model` IReadOnlyModel

#### Returns

string

### 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

`model` IConventionModel

#### Returns

ConfigurationSource?

### GetHiLoSequenceName(IReadOnlyModel)

Returns the name to use for the default hi-lo sequence.

    public static string GetHiLoSequenceName(this IReadOnlyModel model)

#### Parameters

`model` IReadOnlyModel

  The 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

`model` IConventionModel

  The 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

`model` IReadOnlyModel

  The 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

`model` IConventionModel

  The 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

`model` IMutableModel
`schema` string
`name` string
`lcCollate` string
`lcCtype` string
`provider` string
`deterministic` bool?

#### Returns

PostgresCollation

### GetOrAddPostgresEnum(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 PostgresEnum GetOrAddPostgresEnum(this IConventionModel model, string? schema, string name, string[] labels)

#### Parameters

`model` IConventionModel
`schema` string
`name` string
`labels` string[]

#### Returns

PostgresEnum

### 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

`model` IMutableModel
`schema` string
`name` string
`labels` string[]

#### Returns

PostgresEnum

### 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

`model` IConventionModel
`schema` string
`name` string
`version` string

#### Returns

PostgresExtension

### 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

`model` IMutableModel
`schema` string
`name` string
`version` string

#### Returns

PostgresExtension

### 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

`model` IMutableModel
`schema` string
`name` string
`subtype` string
`canonicalFunction` string
`subtypeOpClass` string
`collation` string
`subtypeDiff` string

#### Returns

PostgresRange

### 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

`model` IReadOnlyModel

#### Returns

IReadOnlyList<PostgresEnum>

### 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

`model` IReadOnlyModel

#### Returns

IReadOnlyList<PostgresExtension>

### GetSequenceNameSuffix(IReadOnlyModel)

Returns the suffix to append to the name of automatically created sequences.

    public static string GetSequenceNameSuffix(this IReadOnlyModel model)

#### Parameters

`model` IReadOnlyModel

  The 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

`model` IConventionModel

  The 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

`model` IReadOnlyModel

  The 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

`model` IConventionModel

  The 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

`model` IReadOnlyModel

#### Returns

string

### 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

`model` IConventionModel

#### Returns

ConfigurationSource?

### 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

`model` IReadOnlyModel

  The model.

#### Returns

NpgsqlValueGenerationStrategy?

  The default NpgsqlValueGenerationStrategy.

### GetValueGenerationStrategyConfigurationSource(IConventionModel)

Returns the ConfigurationSource for the default NpgsqlValueGenerationStrategy.

    public static ConfigurationSource? GetValueGenerationStrategyConfigurationSource(this IConventionModel model)

#### Parameters

`model` IConventionModel

  The 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

`model` IReadOnlyModel

#### Returns

IReadOnlyList<PostgresRange>

### 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

`model` IConventionModel
`template` string
`fromDataAnnotation` bool

#### Returns

string

### 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

`model` IMutableModel
`template` string

### 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

`model` IConventionModel

  The model.

`name` string

  The value to set.

`fromDataAnnotation` bool

  Indicates whether the configuration was specified using a data annotation.

#### Returns

string

### SetHiLoSequenceName(IMutableModel, string?)

Sets the name to use for the default hi-lo sequence.

    public static void SetHiLoSequenceName(this IMutableModel model, string? name)

#### Parameters

`model` IMutableModel

  The model.

`name` string

  The 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

`model` IConventionModel

  The model.

`value` string

  The value to set.

`fromDataAnnotation` bool

  Indicates whether the configuration was specified using a data annotation.

#### Returns

string

### SetHiLoSequenceSchema(IMutableModel, string?)

Sets the schema to use for the default hi-lo sequence.

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

#### Parameters

`model` IMutableModel

  The model.

`value` string

  The 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

`model` IConventionModel

  The model.

`name` string

  The value to set.

`fromDataAnnotation` bool

  Indicates 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

`model` IMutableModel

  The model.

`name` string

  The 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

`model` IConventionModel

  The model.

`value` string

  The value to set.

`fromDataAnnotation` bool

  Indicates 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

`model` IMutableModel

  The model.

`value` string

  The 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

`model` IConventionModel
`tablespace` string
`fromDataAnnotation` bool

#### Returns

string

### 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

`model` IMutableModel
`tablespace` string

### 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

`model` IConventionModel

  The model.

`value` NpgsqlValueGenerationStrategy?

  The value to set.

`fromDataAnnotation` bool

  Indicates whether the configuration was specified using a data annotation.

#### Returns

NpgsqlValueGenerationStrategy?

### 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

`model` IMutableModel

  The model.

`value` NpgsqlValueGenerationStrategy?

  The value to set.