다음을 통해 공유


PropertyBuilder<TProperty> Class

Definition

Provides a simple API for configuring a IMutableProperty.

public class PropertyBuilder<TProperty> : Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
type PropertyBuilder<'Property> = class
    inherit PropertyBuilder
Public Class PropertyBuilder(Of TProperty)
Inherits PropertyBuilder

Type Parameters

TProperty
Inheritance
PropertyBuilder<TProperty>

Remarks

Instances of this class are returned from methods when using the ModelBuilder API and it is not designed to be directly constructed in your application code.

See Modeling entity types and relationships for more information and examples.

Constructors

PropertyBuilder<TProperty>(IMutableProperty)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

PropertyBuilder<TProperty>(InternalPropertyBuilder)

This API supports the Entity Framework Core infrastructure and is not intended to be used directly from your code. This API may change or be removed in future releases.

Properties

Metadata

The property being configured.

(Inherited from PropertyBuilder)

Methods

HasAnnotation(String, Object)

Adds or updates an annotation on the property. If an annotation with the key specified in annotation already exists its value will be updated.

HasConversion(Type, Type, Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type, Type, Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion(Type, Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type, Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion(Type, ValueComparer, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type, ValueComparer, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion(Type, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion(Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion(Type)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion(ValueConverter, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

HasConversion(ValueConverter, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

(Inherited from PropertyBuilder)
HasConversion(ValueConverter, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

HasConversion(ValueConverter, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

(Inherited from PropertyBuilder)
HasConversion(ValueConverter)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

HasConversion(ValueConverter)

Configures the property so that the property value is converted to and from the database using the given ValueConverter.

(Inherited from PropertyBuilder)
HasConversion<TConversion,TComparer,TProviderComparer>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion,TComparer,TProviderComparer>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion<TConversion,TComparer>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion,TComparer>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion<TConversion>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion>()

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion<TConversion>(ValueComparer, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion>(ValueComparer, ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion<TConversion>(ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

HasConversion<TConversion>(ValueComparer)

Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.

(Inherited from PropertyBuilder)
HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given conversion expressions.

HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given conversion expressions.

HasConversion<TProvider>(Expression<Func<TProperty,TProvider>>, Expression<Func<TProvider,TProperty>>)

Configures the property so that the property value is converted to and from the database using the given conversion expressions.

HasConversion<TProvider>(ValueConverter<TProperty,TProvider>, ValueComparer, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter<TModel,TProvider>.

HasConversion<TProvider>(ValueConverter<TProperty,TProvider>, ValueComparer)

Configures the property so that the property value is converted to and from the database using the given ValueConverter<TModel,TProvider>.

HasConversion<TProvider>(ValueConverter<TProperty,TProvider>)

Configures the property so that the property value is converted to and from the database using the given ValueConverter<TModel,TProvider>.

HasField(String)

Sets the backing field to use for this property.

HasField(String)

Sets the backing field to use for this property.

(Inherited from PropertyBuilder)
HasMaxLength(Int32)

Configures the maximum length of data that can be stored in this property. Maximum length can only be set on array properties (including String properties).

HasPrecision(Int32, Int32)

Configures the precision and scale of the property.

HasPrecision(Int32, Int32)

Configures the precision and scale of the property.

(Inherited from PropertyBuilder)
HasPrecision(Int32)

Configures the precision of the property.

HasPrecision(Int32)

Configures the precision of the property.

(Inherited from PropertyBuilder)
HasSentinel(Object)

Configures the value that will be used to determine if the property has been set or not. If the property is set to the sentinel value, then it is considered not set. By default, the sentinel value is the CLR default value for the type of the property.

HasSentinel(Object)

Configures the value that will be used to determine if the property has been set or not. If the property is set to the sentinel value, then it is considered not set. By default, the sentinel value is the CLR default value for the type of the property.

(Inherited from PropertyBuilder)
HasSentinel(TProperty)

Configures the value that will be used to determine if the property has been set or not. If the property is set to the sentinel value, then it is considered not set. By default, the sentinel value is the CLR default value for the type of the property.

HasValueGenerator(Func<IProperty,IEntityType,ValueGenerator>)

Configures a factory for creating a ValueGenerator to use to generate values for this property.

HasValueGenerator(Func<IProperty,IEntityType,ValueGenerator>)

Configures a factory for creating a ValueGenerator to use to generate values for this property.

(Inherited from PropertyBuilder)
HasValueGenerator(Func<IProperty,ITypeBase,ValueGenerator>)

Configures a factory for creating a ValueGenerator to use to generate values for this property.

HasValueGenerator(Func<IProperty,ITypeBase,ValueGenerator>)

Configures a factory for creating a ValueGenerator to use to generate values for this property.

(Inherited from PropertyBuilder)
HasValueGenerator(Type)

Configures the ValueGenerator that will generate values for this property.

HasValueGenerator(Type)

Configures the ValueGenerator that will generate values for this property.

(Inherited from PropertyBuilder)
HasValueGenerator<TGenerator>()

Configures the ValueGenerator that will generate values for this property.

HasValueGenerator<TGenerator>()

Configures the ValueGenerator that will generate values for this property.

(Inherited from PropertyBuilder)
HasValueGeneratorFactory(Type)

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

HasValueGeneratorFactory(Type)

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

(Inherited from PropertyBuilder)
HasValueGeneratorFactory<TFactory>()

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

HasValueGeneratorFactory<TFactory>()

Configures the ValueGeneratorFactory for creating a ValueGenerator to use to generate values for this property.

(Inherited from PropertyBuilder)
IsConcurrencyToken(Boolean)

Configures whether this property should be used as a concurrency token. When a property is configured as a concurrency token the value in the database will be checked when an instance of this entity type is updated or deleted during SaveChanges() to ensure it has not changed since the instance was retrieved from the database. If it has changed, an exception will be thrown and the changes will not be applied to the database.

IsRequired(Boolean)

Configures whether this property must have a value assigned or whether null is a valid value. A property can only be configured as non-required if it is based on a CLR type that can be assigned null.

IsRowVersion()

Configures the property as ValueGeneratedOnAddOrUpdate() and IsConcurrencyToken(Boolean).

IsRowVersion()

Configures the property as ValueGeneratedOnAddOrUpdate() and IsConcurrencyToken(Boolean).

(Inherited from PropertyBuilder)
IsUnicode(Boolean)

Configures the property as capable of persisting unicode characters. Can only be set on String properties.

IsUnicode(Boolean)

Configures whether the property as capable of persisting unicode characters. Can only be set on String properties.

(Inherited from PropertyBuilder)
UsePropertyAccessMode(PropertyAccessMode)

Sets the PropertyAccessMode to use for this property.

By default, the backing field, if one is found by convention or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. Calling this method witll change that behavior for this property as described in the PropertyAccessMode enum.

Calling this method overrrides for this property any access mode that was set on the entity type or model.

UsePropertyAccessMode(PropertyAccessMode)

Sets the PropertyAccessMode to use for this property.

UsePropertyAccessMode(PropertyAccessMode)

Sets the PropertyAccessMode to use for this property.

By default, the backing field, if one is found by convention or has been specified, is used when new objects are constructed, typically when entities are queried from the database. Properties are used for all other accesses. Calling this method witll change that behavior for this property as described in the PropertyAccessMode enum.

Calling this method overrrides for this property any access mode that was set on the entity type or model.

(Inherited from PropertyBuilder)
UsePropertyAccessMode(PropertyAccessMode)

Sets the PropertyAccessMode to use for this property.

(Inherited from PropertyBuilder)
ValueGeneratedNever()

Configures a property to never have a value generated when an instance of this entity type is saved.

ValueGeneratedOnAdd()

Configures a property to have a value generated only when saving a new entity, unless a non-null, non-temporary value has been set, in which case the set value will be saved instead. The value may be generated by a client-side value generator or may be generated by the database as part of saving the entity.

ValueGeneratedOnAddOrUpdate()

Configures a property to have a value generated when saving a new or existing entity.

ValueGeneratedOnUpdate()

Configures a property to have a value generated when saving an existing entity.

ValueGeneratedOnUpdate()

Configures a property to have a value generated when saving an existing entity.

(Inherited from PropertyBuilder)
ValueGeneratedOnUpdateSometimes()

Configures a property to have a value generated under certain conditions when saving an existing entity.

ValueGeneratedOnUpdateSometimes()

Configures a property to have a value generated under certain conditions when saving an existing entity.

(Inherited from PropertyBuilder)

Explicit Interface Implementations

IInfrastructure<IConventionPropertyBuilder>.Instance

The internal builder being used to configure the property.

(Inherited from PropertyBuilder)
IInfrastructure<IMutableModel>.Instance

The model that the property belongs to.

(Inherited from PropertyBuilder)
IInfrastructure<InternalPropertyBuilder>.Instance

The internal builder being used to configure the property.

(Inherited from PropertyBuilder)

Extension Methods

IsETagConcurrency(PropertyBuilder)

Configures this property to be the etag concurrency token.

IsETagConcurrency<TProperty>(PropertyBuilder<TProperty>)

Configures this property to be the etag concurrency token.

IsVector(PropertyBuilder, DistanceFunction, Int32)

Configures the property as a vector for Azure Cosmos DB.

IsVector<TProperty>(PropertyBuilder<TProperty>, DistanceFunction, Int32)

Configures the property as a vector for Azure Cosmos DB.

ToJsonProperty(PropertyBuilder, String)

Configures the property name that the property is mapped to when targeting Azure Cosmos.

ToJsonProperty<TProperty>(PropertyBuilder<TProperty>, String)

Configures the property name that the property is mapped to when targeting Azure Cosmos.

GetInfrastructure<T>(IInfrastructure<T>)

Gets the value from a property that is being hidden using IInfrastructure<T>.

This method is typically used by database providers (and other extensions). It is generally not used in application code.

HasColumnName(PropertyBuilder, String)

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

HasColumnName<TProperty>(PropertyBuilder<TProperty>, String)

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

HasColumnOrder(PropertyBuilder, Nullable<Int32>)

Configures the order of the column the property is mapped to.

HasColumnOrder<TProperty>(PropertyBuilder<TProperty>, Nullable<Int32>)

Configures the order of the column the property is mapped to.

HasColumnType(PropertyBuilder, String)

Configures the data type of the column that the property maps to when targeting a relational database. This should be the complete type name, including precision, scale, length, etc.

HasColumnType<TProperty>(PropertyBuilder<TProperty>, String)

Configures the data type of the column that the property maps to when targeting a relational database. This should be the complete type name, including precision, scale, length, etc.

HasComment(PropertyBuilder, String)

Configures a comment to be applied to the column

HasComment<TProperty>(PropertyBuilder<TProperty>, String)

Configures a comment to be applied to the column

HasComputedColumnSql(PropertyBuilder, String, Nullable<Boolean>)

Configures the property to map to a computed column when targeting a relational database.

HasComputedColumnSql(PropertyBuilder, String)

Configures the property to map to a computed column when targeting a relational database.

HasComputedColumnSql(PropertyBuilder)

Configures the property to map to a computed column when targeting a relational database.

HasComputedColumnSql<TProperty>(PropertyBuilder<TProperty>, String, Nullable<Boolean>)

Configures the property to map to a computed column when targeting a relational database.

HasComputedColumnSql<TProperty>(PropertyBuilder<TProperty>, String)

Configures the property to map to a computed column when targeting a relational database.

HasComputedColumnSql<TProperty>(PropertyBuilder<TProperty>)

Configures the property to map to a computed column 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(PropertyBuilder)

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<TProperty>(PropertyBuilder<TProperty>)

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

HasDefaultValueSql(PropertyBuilder, String)

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

HasDefaultValueSql(PropertyBuilder)

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

HasDefaultValueSql<TProperty>(PropertyBuilder<TProperty>, String)

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

HasDefaultValueSql<TProperty>(PropertyBuilder<TProperty>)

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

HasJsonPropertyName(PropertyBuilder, String)

Configures the property of an entity mapped to a JSON column, mapping the entity property to a specific JSON property, rather than using the entity property name.

HasJsonPropertyName<TProperty>(PropertyBuilder<TProperty>, String)

Configures the property of an entity mapped to a JSON column, mapping the entity property to a specific JSON property, rather than using the entity property name.

IsFixedLength(PropertyBuilder, Boolean)

Configures the property as capable of storing only fixed-length data, such as strings.

IsFixedLength<TProperty>(PropertyBuilder<TProperty>, Boolean)

Configures the property as capable of storing only fixed-length data, such as strings.

UseCollation(PropertyBuilder, String)

Configures the property to use the given collation. The database column will be created with the given collation, and it will be used implicitly in all collation-sensitive operations.

UseCollation<TProperty>(PropertyBuilder<TProperty>, String)

Configures the property to use the given collation. The database column will be created with the given collation, and it will be used implicitly in all collation-sensitive operations.

ForSqliteHasDimension(PropertyBuilder, Ordinates)

Configures the dimension of the column that the property maps to when targeting SQLite.

ForSqliteHasDimension(PropertyBuilder, Ordinates)
Obsolete.

Configures the dimension of the column that the property maps to when targeting SQLite.

ForSqliteHasDimension<TProperty>(PropertyBuilder<TProperty>, Ordinates)

Configures the dimension of the column that the property maps to when targeting SQLite.

ForSqliteHasDimension<TProperty>(PropertyBuilder<TProperty>, Ordinates)
Obsolete.

Configures the dimension of the column that the property maps to when targeting SQLite.

HasGeometricDimension(PropertyBuilder, Ordinates)

Configures the dimension of the column that the property maps to when targeting SQLite.

HasGeometricDimension<TProperty>(PropertyBuilder<TProperty>, Ordinates)

Configures the dimension of the column that the property maps to when targeting SQLite.

ForSqliteHasColumnName(PropertyBuilder, String)

Configures the column that the property maps to when targeting SQLite.

ForSqliteHasColumnName<TProperty>(PropertyBuilder<TProperty>, String)

Configures the column that the property maps to when targeting SQLite.

ForSqliteHasColumnType(PropertyBuilder, String)

Configures the data type of the column that the property maps to when targeting SQLite.

ForSqliteHasColumnType<TProperty>(PropertyBuilder<TProperty>, String)

Configures the data type of the column that the property maps to when targeting SQLite.

ForSqliteHasDefaultValue(PropertyBuilder, Object)

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

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

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

ForSqliteHasDefaultValueSql(PropertyBuilder, String)

Configures the default value expression for the column that the property maps to when targeting SQLite.

ForSqliteHasDefaultValueSql<TProperty>(PropertyBuilder<TProperty>, String)

Configures the default value expression for the column that the property maps to when targeting SQLite.

ForSqliteHasSrid(PropertyBuilder, Int32)
Obsolete.

Configures the SRID of the column that the property maps to when targeting SQLite.

ForSqliteHasSrid<TProperty>(PropertyBuilder<TProperty>, Int32)
Obsolete.

Configures the SRID of the column that the property maps to when targeting SQLite.

HasSrid(PropertyBuilder, Int32)

Configures the SRID of the column that the property maps to when targeting SQLite.

HasSrid<TProperty>(PropertyBuilder<TProperty>, Int32)

Configures the SRID of the column that the property maps to when targeting SQLite.

ForSqlServerHasColumnName(PropertyBuilder, String)

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

ForSqlServerHasColumnName<TProperty>(PropertyBuilder<TProperty>, String)

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

ForSqlServerHasColumnType(PropertyBuilder, String)

Configures the data type of the column that the property maps to when targeting SQL Server. This should be the complete type name, including precision, scale, length, etc.

ForSqlServerHasColumnType<TProperty>(PropertyBuilder<TProperty>, String)

Configures the data type of the column that the property maps to when targeting SQL Server. This should be the complete type name, including precision, scale, length, etc.

ForSqlServerHasComputedColumnSql(PropertyBuilder, String)

Configures the property to map to a computed column when targeting SQL Server.

ForSqlServerHasComputedColumnSql<TProperty>(PropertyBuilder<TProperty>, String)

Configures the property to map to a computed column when targeting SQL Server.

ForSqlServerHasDefaultValue(PropertyBuilder, Object)

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

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

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

ForSqlServerHasDefaultValueSql(PropertyBuilder, String)

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

ForSqlServerHasDefaultValueSql<TProperty>(PropertyBuilder<TProperty>, String)

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

ForSqlServerUseSequenceHiLo(PropertyBuilder, String, String)
Obsolete.

Configures the key property to use a sequence-based hi-lo pattern to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

ForSqlServerUseSequenceHiLo<TProperty>(PropertyBuilder<TProperty>, String, String)
Obsolete.

Configures the key property to use a sequence-based hi-lo pattern to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

IsSparse(PropertyBuilder, Boolean)

Configures whether the property's column is created as sparse when targeting SQL Server.

IsSparse<TProperty>(PropertyBuilder<TProperty>, Boolean)

Configures whether the property's column is created as sparse when targeting SQL Server.

UseHiLo(PropertyBuilder, String, String)

Configures the key property to use a sequence-based hi-lo pattern to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseHiLo<TProperty>(PropertyBuilder<TProperty>, String, String)

Configures the key property to use a sequence-based hi-lo pattern to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseIdentityColumn(PropertyBuilder, Int32, Int32)

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseIdentityColumn(PropertyBuilder, Int64, Int32)

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseIdentityColumn<TProperty>(PropertyBuilder<TProperty>, Int32, Int32)

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseIdentityColumn<TProperty>(PropertyBuilder<TProperty>, Int64, Int32)

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseSequence(PropertyBuilder, String, String)

Configures the key property to use a sequence-based key value generation pattern to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseSequence<TProperty>(PropertyBuilder<TProperty>, String, String)

Configures the key property to use a sequence-based key value generation pattern to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseSqlServerIdentityColumn(PropertyBuilder, Int32, Int32)
Obsolete.

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseSqlServerIdentityColumn(PropertyBuilder)

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseSqlServerIdentityColumn<TProperty>(PropertyBuilder<TProperty>, Int32, Int32)
Obsolete.

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

UseSqlServerIdentityColumn<TProperty>(PropertyBuilder<TProperty>)

Configures the key property to use the SQL Server IDENTITY feature to generate values for new entities, when targeting SQL Server. This method sets the property to be OnAdd.

Applies to