Share via


SqlServerPropertyBuilderExtensions.HasDefaultValue Method

Definition

Overloads

Name Description
HasDefaultValue(IConventionPropertyBuilder, Object, String, Boolean)

Configures the default value for the column that the property maps to when targeting SQL Server.

HasDefaultValue(PropertyBuilder, Object, String)

Configures the default value for the column that the property maps to when targeting SQL Server.

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

Configures the default value for the column that the property maps to when targeting SQL Server.

HasDefaultValue(IConventionPropertyBuilder, Object, String, Boolean)

Source:
SqlServerPropertyBuilderExtensions.cs

Configures the default value for the column that the property maps to when targeting SQL Server.

public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder? HasDefaultValue(this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder propertyBuilder, object? value, string defaultConstraintName, bool fromDataAnnotation = false);
static member HasDefaultValue : Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder * obj * string * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder
<Extension()>
Public Function HasDefaultValue (propertyBuilder As IConventionPropertyBuilder, value As Object, defaultConstraintName As String, 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.

defaultConstraintName
String

The default constraint name.

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 Modeling entity types and relationships, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

HasDefaultValue(PropertyBuilder, Object, String)

Source:
SqlServerPropertyBuilderExtensions.cs

Configures the default value for the column that the property maps to when targeting SQL Server.

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

Parameters

propertyBuilder
PropertyBuilder

The builder for the property being configured.

value
Object

The default value of the column.

defaultConstraintName
String

The default constraint name.

Returns

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

Remarks

See Modeling entity types and relationships, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to

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

Source:
SqlServerPropertyBuilderExtensions.cs

Configures the default value for the column that the property maps to when targeting SQL Server.

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

Type Parameters

TProperty

Parameters

propertyBuilder
PropertyBuilder<TProperty>

The builder for the property being configured.

value
Object

The default value of the column.

defaultConstraintName
String

The default constraint name.

Returns

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

Remarks

See Modeling entity types and relationships, and Accessing SQL Server and Azure SQL databases with EF Core for more information and examples.

Applies to