RuntimeEntityType.AddProperty Method

Definition

Overloads

AddProperty(String, Type, PropertyInfo, FieldInfo, PropertyAccessMode, Boolean, Boolean, ValueGenerated, PropertySaveBehavior, PropertySaveBehavior, Nullable<Int32>, Nullable<Boolean>, Nullable<Int32>, Nullable<Int32>, Type, Func<IProperty,IEntityType,ValueGenerator>, ValueConverter, ValueComparer, ValueComparer, CoreTypeMapping)

Adds a property to this entity type.

AddProperty(String, Type, PropertyInfo, FieldInfo, PropertyAccessMode, Boolean, Boolean, ValueGenerated, PropertySaveBehavior, PropertySaveBehavior, Nullable<Int32>, Nullable<Boolean>, Nullable<Int32>, Nullable<Int32>, Type, Func<IProperty,IEntityType,ValueGenerator>, ValueConverter, ValueComparer, ValueComparer, ValueComparer, CoreTypeMapping)

Adds a property to this entity type.

AddProperty(String, Type, PropertyInfo, FieldInfo, PropertyAccessMode, Boolean, Boolean, ValueGenerated, PropertySaveBehavior, PropertySaveBehavior, Nullable<Int32>, Nullable<Boolean>, Nullable<Int32>, Nullable<Int32>, Type, Func<IProperty,IEntityType,ValueGenerator>, ValueConverter, ValueComparer, ValueComparer, CoreTypeMapping)

Adds a property to this entity type.

public virtual Microsoft.EntityFrameworkCore.Metadata.RuntimeProperty AddProperty (string name, Type clrType, System.Reflection.PropertyInfo? propertyInfo = default, System.Reflection.FieldInfo? fieldInfo = default, Microsoft.EntityFrameworkCore.PropertyAccessMode propertyAccessMode = Microsoft.EntityFrameworkCore.PropertyAccessMode.PreferField, bool nullable = false, bool concurrencyToken = false, Microsoft.EntityFrameworkCore.Metadata.ValueGenerated valueGenerated = Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never, Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior beforeSaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior afterSaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, int? maxLength = default, bool? unicode = default, int? precision = default, int? scale = default, Type? providerPropertyType = default, Func<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.IEntityType,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator>? valueGeneratorFactory = default, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? valueConverter = default, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer = default, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? keyValueComparer = default, Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping? typeMapping = default);
abstract member AddProperty : string * Type * System.Reflection.PropertyInfo * System.Reflection.FieldInfo * Microsoft.EntityFrameworkCore.PropertyAccessMode * bool * bool * Microsoft.EntityFrameworkCore.Metadata.ValueGenerated * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Nullable<int> * Nullable<bool> * Nullable<int> * Nullable<int> * Type * Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping -> Microsoft.EntityFrameworkCore.Metadata.RuntimeProperty
override this.AddProperty : string * Type * System.Reflection.PropertyInfo * System.Reflection.FieldInfo * Microsoft.EntityFrameworkCore.PropertyAccessMode * bool * bool * Microsoft.EntityFrameworkCore.Metadata.ValueGenerated * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Nullable<int> * Nullable<bool> * Nullable<int> * Nullable<int> * Type * Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping -> Microsoft.EntityFrameworkCore.Metadata.RuntimeProperty
Public Overridable Function AddProperty (name As String, clrType As Type, Optional propertyInfo As PropertyInfo = Nothing, Optional fieldInfo As FieldInfo = Nothing, Optional propertyAccessMode As PropertyAccessMode = Microsoft.EntityFrameworkCore.PropertyAccessMode.PreferField, Optional nullable As Boolean = false, Optional concurrencyToken As Boolean = false, Optional valueGenerated As ValueGenerated = Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never, Optional beforeSaveBehavior As PropertySaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, Optional afterSaveBehavior As PropertySaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, Optional maxLength As Nullable(Of Integer) = Nothing, Optional unicode As Nullable(Of Boolean) = Nothing, Optional precision As Nullable(Of Integer) = Nothing, Optional scale As Nullable(Of Integer) = Nothing, Optional providerPropertyType As Type = Nothing, Optional valueGeneratorFactory As Func(Of IProperty, IEntityType, ValueGenerator) = Nothing, Optional valueConverter As ValueConverter = Nothing, Optional valueComparer As ValueComparer = Nothing, Optional keyValueComparer As ValueComparer = Nothing, Optional typeMapping As CoreTypeMapping = Nothing) As RuntimeProperty

Parameters

name
String

The name of the property to add.

clrType
Type

The type of value the property will hold.

propertyInfo
PropertyInfo

The corresponding CLR property or null for a shadow property.

fieldInfo
FieldInfo

The corresponding CLR field or null for a shadow property.

propertyAccessMode
PropertyAccessMode

The PropertyAccessMode used for this property.

nullable
Boolean

A value indicating whether this property can contain null.

concurrencyToken
Boolean

A value indicating whether this property is used as a concurrency token.

valueGenerated
ValueGenerated

A value indicating when a value for this property will be generated by the database.

beforeSaveBehavior
PropertySaveBehavior

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

afterSaveBehavior
PropertySaveBehavior

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

maxLength
Nullable<Int32>

The maximum length of data that is allowed in this property.

unicode
Nullable<Boolean>

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

precision
Nullable<Int32>

The precision of data that is allowed in this property.

scale
Nullable<Int32>

The scale of data that is allowed in this property.

providerPropertyType
Type

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

valueGeneratorFactory
Func<IProperty,IEntityType,ValueGenerator>

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

valueConverter
ValueConverter

The custom ValueConverter set for this property.

valueComparer
ValueComparer

The ValueComparer for this property.

keyValueComparer
ValueComparer

The ValueComparer to use with keys for this property.

typeMapping
CoreTypeMapping

The CoreTypeMapping for this property.

Returns

The newly created property.

Applies to

AddProperty(String, Type, PropertyInfo, FieldInfo, PropertyAccessMode, Boolean, Boolean, ValueGenerated, PropertySaveBehavior, PropertySaveBehavior, Nullable<Int32>, Nullable<Boolean>, Nullable<Int32>, Nullable<Int32>, Type, Func<IProperty,IEntityType,ValueGenerator>, ValueConverter, ValueComparer, ValueComparer, ValueComparer, CoreTypeMapping)

Adds a property to this entity type.

public virtual Microsoft.EntityFrameworkCore.Metadata.RuntimeProperty AddProperty (string name, Type clrType, System.Reflection.PropertyInfo? propertyInfo = default, System.Reflection.FieldInfo? fieldInfo = default, Microsoft.EntityFrameworkCore.PropertyAccessMode propertyAccessMode = Microsoft.EntityFrameworkCore.PropertyAccessMode.PreferField, bool nullable = false, bool concurrencyToken = false, Microsoft.EntityFrameworkCore.Metadata.ValueGenerated valueGenerated = Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never, Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior beforeSaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior afterSaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, int? maxLength = default, bool? unicode = default, int? precision = default, int? scale = default, Type? providerPropertyType = default, Func<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.IEntityType,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator>? valueGeneratorFactory = default, Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter? valueConverter = default, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? valueComparer = default, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? keyValueComparer = default, Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer? providerValueComparer = default, Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping? typeMapping = default);
abstract member AddProperty : string * Type * System.Reflection.PropertyInfo * System.Reflection.FieldInfo * Microsoft.EntityFrameworkCore.PropertyAccessMode * bool * bool * Microsoft.EntityFrameworkCore.Metadata.ValueGenerated * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Nullable<int> * Nullable<bool> * Nullable<int> * Nullable<int> * Type * Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping -> Microsoft.EntityFrameworkCore.Metadata.RuntimeProperty
override this.AddProperty : string * Type * System.Reflection.PropertyInfo * System.Reflection.FieldInfo * Microsoft.EntityFrameworkCore.PropertyAccessMode * bool * bool * Microsoft.EntityFrameworkCore.Metadata.ValueGenerated * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior * Nullable<int> * Nullable<bool> * Nullable<int> * Nullable<int> * Type * Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping -> Microsoft.EntityFrameworkCore.Metadata.RuntimeProperty
Public Overridable Function AddProperty (name As String, clrType As Type, Optional propertyInfo As PropertyInfo = Nothing, Optional fieldInfo As FieldInfo = Nothing, Optional propertyAccessMode As PropertyAccessMode = Microsoft.EntityFrameworkCore.PropertyAccessMode.PreferField, Optional nullable As Boolean = false, Optional concurrencyToken As Boolean = false, Optional valueGenerated As ValueGenerated = Microsoft.EntityFrameworkCore.Metadata.ValueGenerated.Never, Optional beforeSaveBehavior As PropertySaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, Optional afterSaveBehavior As PropertySaveBehavior = Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior.Save, Optional maxLength As Nullable(Of Integer) = Nothing, Optional unicode As Nullable(Of Boolean) = Nothing, Optional precision As Nullable(Of Integer) = Nothing, Optional scale As Nullable(Of Integer) = Nothing, Optional providerPropertyType As Type = Nothing, Optional valueGeneratorFactory As Func(Of IProperty, IEntityType, ValueGenerator) = Nothing, Optional valueConverter As ValueConverter = Nothing, Optional valueComparer As ValueComparer = Nothing, Optional keyValueComparer As ValueComparer = Nothing, Optional providerValueComparer As ValueComparer = Nothing, Optional typeMapping As CoreTypeMapping = Nothing) As RuntimeProperty

Parameters

name
String

The name of the property to add.

clrType
Type

The type of value the property will hold.

propertyInfo
PropertyInfo

The corresponding CLR property or null for a shadow property.

fieldInfo
FieldInfo

The corresponding CLR field or null for a shadow property.

propertyAccessMode
PropertyAccessMode

The PropertyAccessMode used for this property.

nullable
Boolean

A value indicating whether this property can contain null.

concurrencyToken
Boolean

A value indicating whether this property is used as a concurrency token.

valueGenerated
ValueGenerated

A value indicating when a value for this property will be generated by the database.

beforeSaveBehavior
PropertySaveBehavior

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

afterSaveBehavior
PropertySaveBehavior

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

maxLength
Nullable<Int32>

The maximum length of data that is allowed in this property.

unicode
Nullable<Boolean>

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

precision
Nullable<Int32>

The precision of data that is allowed in this property.

scale
Nullable<Int32>

The scale of data that is allowed in this property.

providerPropertyType
Type

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

valueGeneratorFactory
Func<IProperty,IEntityType,ValueGenerator>

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

valueConverter
ValueConverter

The custom ValueConverter set for this property.

valueComparer
ValueComparer

The ValueComparer for this property.

keyValueComparer
ValueComparer

The ValueComparer to use with keys for this property.

providerValueComparer
ValueComparer

The ValueComparer to use for the provider values for this property.

typeMapping
CoreTypeMapping

The CoreTypeMapping for this property.

Returns

The newly created property.

Applies to