Share via

ConventionPropertyBaseExtensions.SetField Method


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: 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
Public Sub SetField (property As IConventionPropertyBase, fieldName As String, Optional fromDataAnnotation As Boolean = false)



The property for which the backing field should be set.


The name of the field to use.


Indicates whether the configuration was specified using a data annotation.

Applies to