# Class NpgsqlEntityTypeBuilderExtensions

Namespace
  Microsoft.EntityFrameworkCore

Assembly
  Npgsql.EntityFrameworkCore.PostgreSQL.dll

Npgsql-specific extension methods for EntityTypeBuilder.

    public static class NpgsqlEntityTypeBuilderExtensions

Inheritance
  object
  NpgsqlEntityTypeBuilderExtensions

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.

## Methods

### CanSetIsUnlogged(IConventionEntityTypeBuilder, bool, bool)

Returns a value indicating whether the mapped table can be configured to use an unlogged table when targeting Npgsql.

    public static bool CanSetIsUnlogged(this IConventionEntityTypeBuilder entityTypeBuilder, bool unlogged = true, bool fromDataAnnotation = false)

#### Parameters

`entityTypeBuilder` IConventionEntityTypeBuilder

  The builder for the entity type being configured.

`unlogged` bool

  True to configure the entity to use an unlogged table; otherwise, false.

`fromDataAnnotation` bool

  Indicates whether the configuration was specified using a data annotation.

#### Returns

bool

  The same builder instance so that multiple calls can be chained.

#### Remarks

See: https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED

### CanSetStorageParameter(IConventionEntityTypeBuilder, string, object?, bool)

Returns a value indicating whether the PostgreSQL storage parameter is set on the table created for this entity.

    public static bool CanSetStorageParameter(this IConventionEntityTypeBuilder entityTypeBuilder, string parameterName, object? parameterValue, bool fromDataAnnotation = false)

#### Parameters

`entityTypeBuilder` IConventionEntityTypeBuilder

  The builder for the entity type being configured.

`parameterName` string

  The name of the storage parameter.

`parameterValue` object

  The value of the storage parameter.

`fromDataAnnotation` bool

  Indicates whether the configuration was specified using a data annotation.

#### Returns

bool

  `true` if the mapped table can be configured as with the storage parameter.

#### Remarks

See https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS

### HasGeneratedTsVectorColumn<TEntity>(EntityTypeBuilder<TEntity>, Expression<Func<TEntity, NpgsqlTsVector>>, string, Expression<Func<TEntity, object>>)

Configures a property on this entity to be a full-text search tsvector column over other given properties.

    public static EntityTypeBuilder<TEntity> HasGeneratedTsVectorColumn<TEntity>(this EntityTypeBuilder<TEntity> entityTypeBuilder, Expression<Func<TEntity, NpgsqlTsVector>> tsVectorPropertyExpression, string config, Expression<Func<TEntity, object>> includeExpression) where TEntity : class

#### Parameters

`entityTypeBuilder` EntityTypeBuilder<TEntity>

  The builder for the entity being configured.

`tsVectorPropertyExpression` Expression<Func<TEntity, NpgsqlTsVector>>

  A lambda expression representing the property to be configured as a tsvector column (`blog => blog.Url`).

`config` string

  The text search configuration for this generated tsvector property, or `null` if this is not a generated tsvector property.

  See https://www.postgresql.org/docs/current/textsearch-controls.html for more information.

`includeExpression` Expression<Func<TEntity, object>>

  A lambda expression representing the property(s) to be included in the tsvector column (`blog => blog.Url`).

  If multiple properties are to be included then specify an anonymous type including the properties (`post => new { post.Title, post.BlogId }`).

#### Returns

EntityTypeBuilder<TEntity>

  A builder to further configure the property.

#### Type Parameters

`TEntity`

### HasStorageParameter(EntityTypeBuilder, string, object?)

Sets a PostgreSQL storage parameter on the table created for this entity.

    public static EntityTypeBuilder HasStorageParameter(this EntityTypeBuilder entityTypeBuilder, string parameterName, object? parameterValue)

#### Parameters

`entityTypeBuilder` EntityTypeBuilder

  The builder for the entity type being configured.

`parameterName` string

  The name of the storage parameter.

`parameterValue` object

  The value of the storage parameter.

#### Returns

EntityTypeBuilder

  The same builder instance so that multiple calls can be chained.

#### Remarks

See https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS

### HasStorageParameter(IConventionEntityTypeBuilder, string, object?, bool)

Sets a PostgreSQL storage parameter on the table created for this entity.

    public static IConventionEntityTypeBuilder? HasStorageParameter(this IConventionEntityTypeBuilder entityTypeBuilder, string parameterName, object? parameterValue, bool fromDataAnnotation = false)

#### Parameters

`entityTypeBuilder` IConventionEntityTypeBuilder

  The builder for the entity type being configured.

`parameterName` string

  The name of the storage parameter.

`parameterValue` object

  The value of the storage parameter.

`fromDataAnnotation` bool

  Indicates whether the configuration was specified using a data annotation.

#### Returns

IConventionEntityTypeBuilder

  The same builder instance so that multiple calls can be chained.

#### Remarks

See https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS

### HasStorageParameter<TEntity>(EntityTypeBuilder<TEntity>, string, object?)

Sets a PostgreSQL storage parameter on the table created for this entity.

    public static EntityTypeBuilder<TEntity> HasStorageParameter<TEntity>(this EntityTypeBuilder<TEntity> entityTypeBuilder, string parameterName, object? parameterValue) where TEntity : class

#### Parameters

`entityTypeBuilder` EntityTypeBuilder<TEntity>

  The builder for the entity type being configured.

`parameterName` string

  The name of the storage parameter.

`parameterValue` object

  The value of the storage parameter.

#### Returns

EntityTypeBuilder<TEntity>

  The same builder instance so that multiple calls can be chained.

#### Type Parameters

`TEntity`

#### Remarks

See https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS

### IsUnlogged(EntityTypeBuilder, bool)

Configures the entity to use an unlogged table when targeting Npgsql.

    public static EntityTypeBuilder IsUnlogged(this EntityTypeBuilder entityTypeBuilder, bool unlogged = true)

#### Parameters

`entityTypeBuilder` EntityTypeBuilder

  The builder for the entity type being configured.

`unlogged` bool

  True to configure the entity to use an unlogged table; otherwise, false.

#### Returns

EntityTypeBuilder

  The same builder instance so that multiple calls can be chained.

#### Remarks

See: https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED

### IsUnlogged(IConventionEntityTypeBuilder, bool, bool)

Configures the mapped table to use an unlogged table when targeting Npgsql.

    public static IConventionEntityTypeBuilder? IsUnlogged(this IConventionEntityTypeBuilder entityTypeBuilder, bool unlogged = true, bool fromDataAnnotation = false)

#### Parameters

`entityTypeBuilder` IConventionEntityTypeBuilder

  The builder for the entity type being configured.

`unlogged` bool

  True to configure the entity to use an unlogged table; otherwise, false.

`fromDataAnnotation` bool

  Indicates whether the configuration was specified using a data annotation.

#### Returns

IConventionEntityTypeBuilder

  The same builder instance so that multiple calls can be chained.

#### Remarks

See: https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED

### IsUnlogged<TEntity>(EntityTypeBuilder<TEntity>, bool)

Configures the mapped table to use an unlogged table when targeting Npgsql.

    public static EntityTypeBuilder<TEntity> IsUnlogged<TEntity>(this EntityTypeBuilder<TEntity> entityTypeBuilder, bool unlogged = true) where TEntity : class

#### Parameters

`entityTypeBuilder` EntityTypeBuilder<TEntity>

  The builder for the entity type being configured.

`unlogged` bool

  True to configure the entity to use an unlogged table; otherwise, false.

#### Returns

EntityTypeBuilder<TEntity>

  The same builder instance so that multiple calls can be chained.

#### Type Parameters

`TEntity`

#### Remarks

See: https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED

### UseCockroachDbInterleaveInParent(EntityTypeBuilder, Type, List<string>)

Specifies that the CockroachDB-specific "interleave in parent" feature should be used.

    public static EntityTypeBuilder UseCockroachDbInterleaveInParent(this EntityTypeBuilder entityTypeBuilder, Type parentTableType, List<string> interleavePrefix)

#### Parameters

`entityTypeBuilder` EntityTypeBuilder
`parentTableType` Type
`interleavePrefix` List<string>

#### Returns

EntityTypeBuilder

### UseCockroachDbInterleaveInParent<TEntity>(EntityTypeBuilder<TEntity>, Type, List<string>)

Specifies that the CockroachDB-specific "interleave in parent" feature should be used.

    public static EntityTypeBuilder<TEntity> UseCockroachDbInterleaveInParent<TEntity>(this EntityTypeBuilder<TEntity> entityTypeBuilder, Type parentTableType, List<string> interleavePrefix) where TEntity : class

#### Parameters

`entityTypeBuilder` EntityTypeBuilder<TEntity>
`parentTableType` Type
`interleavePrefix` List<string>

#### Returns

EntityTypeBuilder<TEntity>

#### Type Parameters

`TEntity`

### UseXminAsConcurrencyToken(EntityTypeBuilder)

Configures using the auto-updating system column `xmin` as the optimistic concurrency token.

    [Obsolete("Use EF Core's standard IsRowVersion() or [Timestamp], see https://learn.microsoft.com/ef/core/saving/concurrency")]
    public static EntityTypeBuilder UseXminAsConcurrencyToken(this EntityTypeBuilder entityTypeBuilder)

#### Parameters

`entityTypeBuilder` EntityTypeBuilder

  The builder for the entity type being configured.

#### Returns

EntityTypeBuilder

  The same builder instance so that multiple calls can be chained.

#### Remarks

See Concurrency tokens for more information on using optimistic concurrency in PostgreSQL.

### UseXminAsConcurrencyToken<TEntity>(EntityTypeBuilder<TEntity>)

Configures using the auto-updating system column `xmin` as the optimistic concurrency token.

    [Obsolete("Use EF Core's standard IsRowVersion() or [Timestamp], see https://learn.microsoft.com/ef/core/saving/concurrency")]
    public static EntityTypeBuilder<TEntity> UseXminAsConcurrencyToken<TEntity>(this EntityTypeBuilder<TEntity> entityTypeBuilder) where TEntity : class

#### Parameters

`entityTypeBuilder` EntityTypeBuilder<TEntity>

  The builder for the entity type being configured.

#### Returns

EntityTypeBuilder<TEntity>

  The same builder instance so that multiple calls can be chained.

#### Type Parameters

`TEntity`

#### Remarks

See http://www.npgsql.org/efcore/miscellaneous.html#optimistic-concurrency-and-concurrency-tokens