Delen via


ConventionPropertyBaseExtensions.SetField Method

Definition

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.

Backing fields are normally found by convention as described here: http://go.microsoft.com/fwlink/?LinkId=723277. 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(IConventionPropertyBase, Nullable<PropertyAccessMode>, Boolean).

public static void SetField (this Microsoft.EntityFrameworkCore.Metadata.IConventionPropertyBase property, string fieldName, bool fromDataAnnotation = false);
static member SetField : Microsoft.EntityFrameworkCore.Metadata.IConventionPropertyBase * string * bool -> unit
<Extension()>
Public Sub SetField (property As IConventionPropertyBase, fieldName As String, Optional fromDataAnnotation As Boolean = false)

Parameters

property
IConventionPropertyBase

The property for which the backing field should be set.

fieldName
String

The name of the field to use.

fromDataAnnotation
Boolean

Indicates whether the configuration was specified using a data annotation.

Applies to