Share via


RelationalPropertyBuilderExtensions.HasDefaultValue Method

Definition

Overloads

HasDefaultValue(PropertyBuilder)

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

HasDefaultValue(PropertyBuilder, Object)

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

HasDefaultValue(IConventionPropertyBuilder, Object, Boolean)

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

HasDefaultValue<TProperty>(PropertyBuilder<TProperty>)

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

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

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

HasDefaultValue(PropertyBuilder)

Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs

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

public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder);
static member HasDefaultValue : Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
<Extension()>
Public Function HasDefaultValue (propertyBuilder As PropertyBuilder) As PropertyBuilder

Parameters

propertyBuilder
PropertyBuilder

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

HasDefaultValue(PropertyBuilder, Object)

Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs

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

public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder, object value);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder, object value = default);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder, object? value);
static member HasDefaultValue : Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder * obj -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
<Extension()>
Public Function HasDefaultValue (propertyBuilder As PropertyBuilder, value As Object) As PropertyBuilder
<Extension()>
Public Function HasDefaultValue (propertyBuilder As PropertyBuilder, Optional value As Object = Nothing) As PropertyBuilder

Parameters

propertyBuilder
PropertyBuilder

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

HasDefaultValue(IConventionPropertyBuilder, Object, Boolean)

Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs

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

public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder propertyBuilder, object value, bool fromDataAnnotation = false);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder? HasDefaultValue (this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder propertyBuilder, object? value, bool fromDataAnnotation = false);
static member HasDefaultValue : Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder * obj * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder
<Extension()>
Public Function HasDefaultValue (propertyBuilder As IConventionPropertyBuilder, value As Object, Optional fromDataAnnotation As Boolean = false) As IConventionPropertyBuilder

Parameters

propertyBuilder
IConventionPropertyBuilder

The builder for the property being configured.

value
Object

The default value of the column.

fromDataAnnotation
Boolean

Indicates whether the configuration was specified using a data annotation.

Returns

The same builder instance if the configuration was applied, null otherwise.

Remarks

See Database default values for more information and examples.

Applies to

HasDefaultValue<TProperty>(PropertyBuilder<TProperty>)

Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs

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

public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasDefaultValue<TProperty> (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> propertyBuilder);
static member HasDefaultValue : Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
<Extension()>
Public Function HasDefaultValue(Of TProperty) (propertyBuilder As PropertyBuilder(Of TProperty)) As PropertyBuilder(Of TProperty)

Type Parameters

TProperty

The type of the property being configured.

Parameters

propertyBuilder
PropertyBuilder<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

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

Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs
Source:
RelationalPropertyBuilderExtensions.cs

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

public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasDefaultValue<TProperty> (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> propertyBuilder, object value);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasDefaultValue<TProperty> (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> propertyBuilder, object value = default);
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasDefaultValue<TProperty> (this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> propertyBuilder, object? value);
static member HasDefaultValue : Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property> * obj -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
<Extension()>
Public Function HasDefaultValue(Of TProperty) (propertyBuilder As PropertyBuilder(Of TProperty), value As Object) As PropertyBuilder(Of TProperty)
<Extension()>
Public Function HasDefaultValue(Of TProperty) (propertyBuilder As PropertyBuilder(Of TProperty), Optional value As Object = Nothing) As PropertyBuilder(Of TProperty)

Type Parameters

TProperty

The type of the property being configured.

Parameters

propertyBuilder
PropertyBuilder<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