IProperty Interface

Definition

Represents a scalar property of an entity.

public interface IProperty : Microsoft.EntityFrameworkCore.Metadata.IPropertyBase
type IProperty = interface
    interface IPropertyBase
    interface IAnnotatable
Public Interface IProperty
Implements IPropertyBase
Derived
Implements

Properties

AfterSaveBehavior

Gets a value indicating whether or not this property can be modified after the entity is saved to the database.

If Throw, then an exception will be thrown if a new value is assigned to this property after the entity exists in the database.

If Ignore, then any modification to the property value of an entity that already exists in the database will be ignored.

BeforeSaveBehavior

Gets a value indicating whether or not this property can be modified before the entity is saved to the database.

If Throw, then an exception will be thrown if a value is assigned to this property when it is in the Added state.

If Ignore, then any value set will be ignored when it is in the Added state.

ClrType

Gets the type of value that this property holds.

DeclaringEntityType

Gets the entity type that this property belongs to.

DeclaringType

Gets the type that this property belongs to.

(Inherited from IPropertyBase)
FieldInfo

Gets the FieldInfo for the underlying CLR field for this property. This may be null for shadow properties or if the backing field for the property is not known.

(Inherited from IPropertyBase)
IsConcurrencyToken

Gets a value indicating whether this property is 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.

IsNullable

Gets a value indicating whether this property can contain null.

IsReadOnlyAfterSave

This property is obsolete. Use BeforeSaveBehavior instead.

IsReadOnlyBeforeSave

This property is obsolete. Use BeforeSaveBehavior instead.

IsShadowProperty

Gets a value indicating whether this is a shadow property. A shadow property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

IsStoreGeneratedAlways

This property is obsolete. Use BeforeSaveBehavior or AfterSaveBehavior instead.

Item[String]

Gets the value annotation with the given name, returning null if it does not exist.

(Inherited from IAnnotatable)
Name

Gets the name of the property.

(Inherited from IPropertyBase)
PropertyInfo

Gets the PropertyInfo for the underlying CLR property that this object represents. This may be null for shadow properties or properties mapped directly to fields.

(Inherited from IPropertyBase)
RequiresValueGenerator

Gets a value indicating whether this property requires a ValueGenerator to generate values when new entities are added to the context.

ValueGenerated

Gets a value indicating when a value for this property will be generated by the database. Even when the property is set to be generated by the database, EF may still attempt to save a specific value (rather than having one generated by the database) when the entity is added and a value is assigned, or the property is marked as modified for an existing entity. See GetBeforeSaveBehavior(IProperty) and GetAfterSaveBehavior(IProperty) for more information.

Methods

FindAnnotation(String)

Gets the annotation with the given name, returning null if it does not exist.

(Inherited from IAnnotatable)
GetAnnotations()

Gets all annotations on the current object.

(Inherited from IAnnotatable)

Extension Methods

GetPropertyName(IProperty)

Returns the property name used when targeting Cosmos.

GetAnnotation(IAnnotatable, String)

Gets the annotation with the given name, throwing if it does not exist.

IsColumnNullable(IProperty)

Checks whether or not the column mapped to the given IProperty will be nullable or not when created in the database.

This can depend not just on the property itself, but also how it is mapped. For example, non-nullable properties in a TPH type hierarchy will be mapped to nullable columns.

Scaffolding(IProperty)
GetFieldName(IPropertyBase)

Gets the name of the backing field for this property, or null if the backing field is not known.

GetGetter(IPropertyBase)

Gets a IClrPropertyGetter for reading the value of this property.

Note that it is an error to call this method for a shadow property (IsShadowProperty(IPropertyBase)) since such a property has no associated MemberInfo.

GetMemberInfo(IPropertyBase, Boolean, Boolean)

Gets the PropertyInfo or FieldInfo that should be used to get or set a value for the given property.

Note that it is an error to call this method for a shadow property (IsShadowProperty(IPropertyBase)) since such a property has no associated MemberInfo.

GetPropertyAccessMode(IPropertyBase)

Gets the PropertyAccessMode being used for this property. null indicates that the default property access mode is being used.

IsShadowProperty(IPropertyBase)

Gets a value indicating whether this is a shadow property. A shadow property is one that does not have a corresponding property in the entity class. The current value for the property is stored in the ChangeTracker rather than being stored in instances of the entity class.

FindContainingPrimaryKey(IProperty)

Gets the primary key that uses this property (including a composite primary key in which this property is included).

FindFirstPrincipal(IProperty)

Finds the first principal property that the given property is constrained by if the given property is part of a foreign key.

FindMapping(IProperty)

Returns the CoreTypeMapping for the given property.

FindTypeMapping(IProperty)

Returns the CoreTypeMapping for the given property.

GetAfterSaveBehavior(IProperty)

Gets a value indicating whether or not this property can be modified after the entity is saved to the database.

If Throw, then an exception will be thrown if a new value is assigned to this property after the entity exists in the database.

If Ignore, then any modification to the property value of an entity that already exists in the database will be ignored.

GetBeforeSaveBehavior(IProperty)

Gets a value indicating whether or not this property can be modified before the entity is saved to the database.

If Throw, then an exception will be thrown if a value is assigned to this property when it is in the Added state.

If Ignore, then any value set will be ignored when it is in the Added state.

GetContainingForeignKeys(IProperty)

Gets all foreign keys that use this property (including composite foreign keys in which this property is included).

GetContainingIndexes(IProperty)

Gets all indexes that use this property (including composite indexes in which this property is included).

GetContainingKeys(IProperty)

Gets all primary or alternate keys that use this property (including composite keys in which this property is included).

GetContainingPrimaryKey(IProperty)

Gets the primary key that uses this property (including a composite primary key in which this property is included).

GetKeyValueComparer(IProperty)

Gets the ValueComparer to use with keys for this property, or null if none is set.

GetMaxLength(IProperty)

Gets the maximum length of data that is allowed in this property. For example, if the property is a String ' then this is the maximum number of characters.

GetProviderClrType(IProperty)

Gets the type that the property value will be converted to before being sent to the database provider.

GetStructuralValueComparer(IProperty)

Gets the ValueComparer to use for structural copies for this property, or null if none is set.

GetTypeMapping(IProperty)

Returns the CoreTypeMapping for the given property from a finalized model.

GetValueComparer(IProperty)

Gets the ValueComparer for this property, or null if none is set.

GetValueConverter(IProperty)

Gets the custom ValueConverter set for this property.

GetValueGeneratorFactory(IProperty)

Gets the factory that has been set to generate values for this property, if any.

IsForeignKey(IProperty)

Gets a value indicating whether this property is used as a foreign key (or part of a composite foreign key).

IsIndex(IProperty)

Gets a value indicating whether this property is used as an index (or part of a composite index).

IsKey(IProperty)

Gets a value indicating whether this property is used as part of a primary or alternate key (or part of a composite primary or alternate key).

IsPrimaryKey(IProperty)

Gets a value indicating whether this property is used as the primary key (or part of a composite primary key).

IsUnicode(IProperty)

Gets a value indicating whether or not the property can persist Unicode characters.

Relational(IProperty)

Gets the relational database specific metadata for a property.

FindRelationalMapping(IProperty)

Returns the RelationalTypeMapping for the given property on a finalized model.

FindSharedTableRootPrimaryKeyProperty(IProperty)

Finds the IProperty that represents the same primary key property as the given property, but potentially in a shared root table.

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

GetColumnName(IProperty)

Returns the name of the column to which the property is mapped.

GetColumnType(IProperty)

Returns the database type of the column to which the property is mapped.

GetComment(IProperty)

Returns the comment for the column this property is mapped to.

GetComputedColumnSql(IProperty)

Returns the SQL expression that is used as the computed value for the column this property is mapped to.

GetDefaultColumnName(IProperty)

Returns the default column name to which the property would be mapped.

GetDefaultValue(IProperty)

Returns the object that is used as the default value for the column this property is mapped to.

GetDefaultValueSql(IProperty)

Returns the SQL expression that is used as the default value for the column this property is mapped to.

GetRelationalTypeMapping(IProperty)

Returns the RelationalTypeMapping for the given property on a finalized model.

IsColumnNullable(IProperty)

Checks whether or not the column mapped to the given IProperty will be nullable or not when created in the database.

This can depend not just on the property itself, but also how it is mapped. For example, non-nullable properties in a TPH type hierarchy will be mapped to nullable columns.

IsFixedLength(IProperty)

Returns a flag indicating if the property as capable of storing only fixed-length data, such as strings.

Sqlite(IProperty)

Gets the SQLite specific metadata for a property.

GetGeometricDimension(IProperty)

Returns the dimension to use when creating a column for this property.

GetSrid(IProperty)

Returns the SRID to use when creating a column for this property.

SqlServer(IProperty)

Gets the SQL Server specific metadata for a property.

FindHiLoSequence(IProperty)

Finds the ISequence in the model to use for the hi-lo pattern.

GetHiLoSequenceName(IProperty)

Returns the name to use for the hi-lo sequence.

GetHiLoSequenceSchema(IProperty)

Returns the schema to use for the hi-lo sequence.

GetIdentityIncrement(IProperty)

Returns the identity increment.

GetIdentitySeed(IProperty)

Returns the identity seed.

GetValueGenerationStrategy(IProperty)

Returns the SqlServerValueGenerationStrategy to use for the property.

If no strategy is set for the property, then the strategy to use will be taken from the IModel.

Applies to