RelationalPrimitiveCollectionBuilderExtensions.HasDefaultValue Method

Definition

Overloads

HasDefaultValue(PrimitiveCollectionBuilder)

Configures the default value for the column that the property maps to when targeting a relational database.

HasDefaultValue(PrimitiveCollectionBuilder, Object)

Configures the default value for the column that the property maps to when targeting a relational database.

HasDefaultValue<TProperty>(PrimitiveCollectionBuilder<TProperty>)

Configures the default value for the column that the property maps to when targeting a relational database.

HasDefaultValue<TProperty>(PrimitiveCollectionBuilder<TProperty>, Object)

Configures the default value for the column that the property maps to when targeting a relational database.

HasDefaultValue(PrimitiveCollectionBuilder)

Source:
RelationalPrimitiveCollectionBuilderExtensions.cs
Source:
RelationalPrimitiveCollectionBuilderExtensions.cs

Configures the default value for the column that the property maps to when targeting a relational database.

C#
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder primitiveCollectionBuilder);

Parameters

primitiveCollectionBuilder
PrimitiveCollectionBuilder

The builder for the property being configured.

Returns

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

Remarks

When called with no argument, this method tells EF that a column has a default value constraint of some sort without needing to specify exactly what it is. This can be useful when mapping EF to an existing database.

See Database default values for more information and examples.

Applies to

Entity Framework Core 9.0 and Entity Framework Core 8.0
Product Versions
Entity Framework Core 8.0, 9.0

HasDefaultValue(PrimitiveCollectionBuilder, Object)

Source:
RelationalPrimitiveCollectionBuilderExtensions.cs
Source:
RelationalPrimitiveCollectionBuilderExtensions.cs

Configures the default value for the column that the property maps to when targeting a relational database.

C#
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder primitiveCollectionBuilder, object? value);

Parameters

primitiveCollectionBuilder
PrimitiveCollectionBuilder

The builder for the property being configured.

value
Object

The default value of the column.

Returns

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

Remarks

See Database default values for more information and examples.

Applies to

Entity Framework Core 9.0 and Entity Framework Core 8.0
Product Versions
Entity Framework Core 8.0, 9.0

HasDefaultValue<TProperty>(PrimitiveCollectionBuilder<TProperty>)

Source:
RelationalPrimitiveCollectionBuilderExtensions.cs
Source:
RelationalPrimitiveCollectionBuilderExtensions.cs

Configures the default value for the column that the property maps to when targeting a relational database.

C#
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder<TProperty> HasDefaultValue<TProperty> (this Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder<TProperty> primitiveCollectionBuilder);

Type Parameters

TProperty

The type of the property being configured.

Parameters

primitiveCollectionBuilder
PrimitiveCollectionBuilder<TProperty>

The builder for the property being configured.

Returns

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

Remarks

When called with no argument, this method tells EF that a column has a default value constraint of some sort without needing to specify exactly what it is. This can be useful when mapping EF to an existing database.

See Database default values for more information and examples.

Applies to

Entity Framework Core 9.0 and Entity Framework Core 8.0
Product Versions
Entity Framework Core 8.0, 9.0

HasDefaultValue<TProperty>(PrimitiveCollectionBuilder<TProperty>, Object)

Source:
RelationalPrimitiveCollectionBuilderExtensions.cs
Source:
RelationalPrimitiveCollectionBuilderExtensions.cs

Configures the default value for the column that the property maps to when targeting a relational database.

C#
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder<TProperty> HasDefaultValue<TProperty> (this Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder<TProperty> primitiveCollectionBuilder, object? value);

Type Parameters

TProperty

The type of the property being configured.

Parameters

primitiveCollectionBuilder
PrimitiveCollectionBuilder<TProperty>

The builder for the property being configured.

value
Object

The default value of the column.

Returns

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

Remarks

See Database default values for more information and examples.

Applies to

Entity Framework Core 9.0 and Entity Framework Core 8.0
Product Versions
Entity Framework Core 8.0, 9.0