次の方法で共有


PropertyBuilder Class

Definition

Provides a simple API for configuring a IMutableProperty.

public class PropertyBuilder : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.IMutableModel>, Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalPropertyBuilder>
public class PropertyBuilder : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalPropertyBuilder>
public class PropertyBuilder : Microsoft.EntityFrameworkCore.Infrastructure.IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Builders.IConventionPropertyBuilder>
type PropertyBuilder = class
    interface IInfrastructure<IMutableModel>
    interface IInfrastructure<InternalPropertyBuilder>
type PropertyBuilder = class
    interface IInfrastructure<InternalPropertyBuilder>
type PropertyBuilder = class
    interface IInfrastructure<IConventionPropertyBuilder>
Public Class PropertyBuilder
Implements IInfrastructure(Of IMutableModel), IInfrastructure(Of InternalPropertyBuilder)
Public Class PropertyBuilder
Implements IInfrastructure(Of InternalPropertyBuilder)
Public Class PropertyBuilder
Implements IInfrastructure(Of IConventionPropertyBuilder)
Inheritance
PropertyBuilder
Derived
Implements
IInfrastructure<IMutableModel> IInfrastructure<Microsoft.EntityFrameworkCore.Metadata.Internal.InternalPropertyBuilder> IInfrastructure<IConventionPropertyBuilder>

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(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(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.

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)

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.

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)

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

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)

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.

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

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.

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)

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

HasField(String)

Sets the backing field to use for this property.

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)

Configures the precision 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.

HasValueGenerator(Func<IProperty,IEntityType,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.

HasValueGenerator(Type)

Configures the ValueGenerator that will generate values for this property.

HasValueGenerator<TGenerator>()

Configures the ValueGenerator that will generate values for this property.

HasValueGeneratorFactory(Type)

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.

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 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).

IsUnicode(Boolean)

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

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.

ValueGeneratedNever()

Configures a property to never have a value generated by the database 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.

ValueGeneratedOnUpdateSometimes()

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

Explicit Interface Implementations

IInfrastructure<IConventionPropertyBuilder>.Instance

The internal builder being used to configure the property.

IInfrastructure<IMutableModel>.Instance

The model that the property belongs to.

IInfrastructure<InternalPropertyBuilder>.Instance

The internal builder being used to configure the property.

Extension Methods

IsETagConcurrency(PropertyBuilder)

Configures this property to be the etag concurrency token.

IsVector(PropertyBuilder, 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.

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.

HasColumnOrder(PropertyBuilder, 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.

HasComment(PropertyBuilder, 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.

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.

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.

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.

IsFixedLength(PropertyBuilder, 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.

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.

HasGeometricDimension(PropertyBuilder, 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.

ForSqliteHasColumnType(PropertyBuilder, 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.

ForSqliteHasDefaultValueSql(PropertyBuilder, 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.

HasSrid(PropertyBuilder, 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.

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.

ForSqlServerHasComputedColumnSql(PropertyBuilder, 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.

ForSqlServerHasDefaultValueSql(PropertyBuilder, 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.

IsSparse(PropertyBuilder, 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.

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.

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.

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.

Applies to