RuntimeTypeBase.AddProperty Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.ITypeBase,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.Json.JsonValueReaderWriter? jsonValueReaderWriter = default, Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping? typeMapping = default, object? sentinel = 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.ITypeBase, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.Storage.Json.JsonValueReaderWriter * Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping * obj -> 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.ITypeBase, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> * Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverter * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.ChangeTracking.ValueComparer * Microsoft.EntityFrameworkCore.Storage.Json.JsonValueReaderWriter * Microsoft.EntityFrameworkCore.Storage.CoreTypeMapping * obj -> 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, ITypeBase, ValueGenerator) = Nothing, Optional valueConverter As ValueConverter = Nothing, Optional valueComparer As ValueComparer = Nothing, Optional keyValueComparer As ValueComparer = Nothing, Optional providerValueComparer As ValueComparer = Nothing, Optional jsonValueReaderWriter As JsonValueReaderWriter = Nothing, Optional typeMapping As CoreTypeMapping = Nothing, Optional sentinel As Object = 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.
A value indicating whether or not the property can persist Unicode characters.
- providerPropertyType
- Type
The type that the property value will be converted to before being sent to the database provider.
- valueGeneratorFactory
- Func<IProperty,ITypeBase,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.
- jsonValueReaderWriter
- JsonValueReaderWriter
The JsonValueReaderWriter for this property.
- typeMapping
- CoreTypeMapping
The CoreTypeMapping for this property.
- sentinel
- Object
The property value to use to consider the property not set.
Returns
The newly created property.
Applies to
Entity Framework