Interface IConventionPropertyBase
- Namespace
- Microsoft.EntityFrameworkCore.Metadata
- Assembly
- Microsoft.EntityFrameworkCore.dll
Base type for navigation and scalar properties.
public interface IConventionPropertyBase : IReadOnlyPropertyBase, IConventionAnnotatable, IReadOnlyAnnotatable
- Inherited Members
- Extension Methods
Remarks
This interface is used during model creation and allows the metadata to be modified. Once the model is built, IReadOnlyPropertyBase represents a read-only view of the same metadata.
See Model building conventions for more information and examples.
Properties
DeclaringType
Gets the type that this property belongs to.
IConventionTypeBase DeclaringType { get; }
Property Value
Methods
GetConfigurationSource()
Returns the configuration source for this property.
ConfigurationSource GetConfigurationSource()
Returns
- ConfigurationSource
The configuration source.
GetFieldInfoConfigurationSource()
Returns the configuration source for FieldInfo.
ConfigurationSource? GetFieldInfoConfigurationSource()
Returns
- ConfigurationSource?
The configuration source for FieldInfo.
GetPropertyAccessModeConfigurationSource()
Returns the configuration source for GetPropertyAccessMode().
ConfigurationSource? GetPropertyAccessModeConfigurationSource()
Returns
- ConfigurationSource?
The configuration source for GetPropertyAccessMode().
SetField(string?, bool)
Sets the underlying CLR field that this property should use. This may be null for shadow properties or if the backing field for the property is not known.
FieldInfo? SetField(string? fieldName, bool fromDataAnnotation = false)
Parameters
fieldName
stringThe name of the field to use.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
Remarks
Backing fields are normally found by convention. This method is useful for setting backing fields explicitly in cases where the correct field is not found by convention.
By default, the backing field, if one is found 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. This can be changed by calling SetPropertyAccessMode(PropertyAccessMode?, bool).
See Backing fields for more information and examples.
SetFieldInfo(FieldInfo?, bool)
Sets the FieldInfo for the underlying CLR field that this property should use.
FieldInfo? SetFieldInfo(FieldInfo? fieldInfo, bool fromDataAnnotation = false)
Parameters
fieldInfo
FieldInfoThe FieldInfo for the underlying CLR field to use.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
Remarks
By default, the backing field, if one is found 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. This can be changed by calling SetPropertyAccessMode(PropertyAccessMode?, bool).
SetPropertyAccessMode(PropertyAccessMode?, bool)
Sets the PropertyAccessMode to use for this property.
PropertyAccessMode? SetPropertyAccessMode(PropertyAccessMode? propertyAccessMode, bool fromDataAnnotation = false)
Parameters
propertyAccessMode
PropertyAccessMode?The PropertyAccessMode, or null to clear the mode set.
fromDataAnnotation
boolIndicates whether the configuration was specified using a data annotation.
Returns
- PropertyAccessMode?
The configured value.