Delen via


PropertyBuilder.HasField(String) Method

Definition

Sets the backing field to use for this property.

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasField (string fieldName);
abstract member HasField : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
override this.HasField : string -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasField (fieldName As String) As PropertyBuilder

Parameters

fieldName
String

The field name.

Returns

The same builder instance so that multiple configuration calls can be chained.

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 UsePropertyAccessMode(PropertyAccessMode).

See Backing fields for more information and examples.

Applies to