SqlServerPropertyBuilderExtensions.HasDefaultValueSql Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| HasDefaultValueSql(PropertyBuilder, String, String) |
Configures the default value expression for the column that the property maps to when targeting SQL Server. |
| HasDefaultValueSql(IConventionPropertyBuilder, String, String, Boolean) |
Configures the default value expression for the column that the property maps to when targeting SQL Server. |
| HasDefaultValueSql<TProperty>(PropertyBuilder<TProperty>, String, String) |
Configures the default value expression for the column that the property maps to when targeting SQL Server. |
HasDefaultValueSql(PropertyBuilder, String, String)
Configures the default value expression for the column that the property maps to when targeting SQL Server.
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasDefaultValueSql(this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder propertyBuilder, string? sql, string defaultConstraintName);
static member HasDefaultValueSql : Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder * string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
<Extension()>
Public Function HasDefaultValueSql (propertyBuilder As PropertyBuilder, sql As String, defaultConstraintName As String) As PropertyBuilder
Parameters
- propertyBuilder
- PropertyBuilder
The builder for the property being configured.
- sql
- String
The SQL expression for 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
HasDefaultValueSql(IConventionPropertyBuilder, String, String, Boolean)
Configures the default value expression for the column that the property maps to when targeting SQL Server.
public static Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder? HasDefaultValueSql(this Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder propertyBuilder, string? sql, string defaultConstraintName, bool fromDataAnnotation = false);
static member HasDefaultValueSql : Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder * string * string * bool -> Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder
<Extension()>
Public Function HasDefaultValueSql (propertyBuilder As IConventionPropertyBuilder, sql As String, defaultConstraintName As String, Optional fromDataAnnotation As Boolean = false) As IConventionPropertyBuilder
Parameters
- propertyBuilder
- IConventionPropertyBuilder
The builder for the property being configured.
- sql
- String
The SQL expression for 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
HasDefaultValueSql<TProperty>(PropertyBuilder<TProperty>, String, String)
Configures the default value expression for the column that the property maps to when targeting SQL Server.
public static Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> HasDefaultValueSql<TProperty>(this Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<TProperty> propertyBuilder, string? sql, string defaultConstraintName);
static member HasDefaultValueSql : Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property> * string * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder<'Property>
<Extension()>
Public Function HasDefaultValueSql(Of TProperty) (propertyBuilder As PropertyBuilder(Of TProperty), sql As String, defaultConstraintName As String) 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.
- sql
- String
The SQL expression for 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.