Class PropertiesConfigurationBuilder<TProperty>
- Namespace
- Microsoft.EntityFrameworkCore.Metadata.Builders
- Assembly
- Microsoft.EntityFrameworkCore.dll
Provides a simple API surface for setting property defaults before conventions run.
public class PropertiesConfigurationBuilder<TProperty> : PropertiesConfigurationBuilder
Type Parameters
TProperty
- Inheritance
-
PropertiesConfigurationBuilder<TProperty>
- Inherited Members
Remarks
Instances of this class are returned from methods when using the ModelConfigurationBuilder API and it is not designed to be directly constructed in your application code.
Constructors
PropertiesConfigurationBuilder(PropertyConfiguration)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
[EntityFrameworkInternal]
public PropertiesConfigurationBuilder(PropertyConfiguration property)
Parameters
property
PropertyConfiguration
Methods
AreUnicode(bool)
Configures the property as capable of persisting unicode characters. Can only be set on string properties.
public virtual PropertiesConfigurationBuilder<TProperty> AreUnicode(bool unicode = true)
Parameters
unicode
boolA value indicating whether the property can contain unicode characters.
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
HaveAnnotation(string, object)
Adds or updates an annotation on the property. If an annotation with the key specified in
annotation
already exists its value will be updated.
public virtual PropertiesConfigurationBuilder<TProperty> HaveAnnotation(string annotation, object value)
Parameters
annotation
stringThe key of the annotation to be added or updated.
value
objectThe value to be stored in the annotation.
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
HaveConversion(Type)
Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.
public virtual PropertiesConfigurationBuilder<TProperty> HaveConversion(Type conversionType)
Parameters
conversionType
TypeThe type to convert to and from or a type that inherits from ValueConverter.
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
HaveConversion(Type, Type?)
Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.
public virtual PropertiesConfigurationBuilder<TProperty> HaveConversion(Type conversionType, Type? comparerType)
Parameters
conversionType
TypeThe type to convert to and from or a type that inherits from ValueConverter.
comparerType
TypeA type that inherits from ValueComparer.
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
HaveConversion<TConversion>()
Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.
public virtual PropertiesConfigurationBuilder<TProperty> HaveConversion<TConversion>()
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
Type Parameters
TConversion
The type to convert to and from or a type that inherits from ValueConverter.
HaveConversion<TConversion, TComparer>()
Configures the property so that the property value is converted before writing to the database and converted back when reading from the database.
public virtual PropertiesConfigurationBuilder<TProperty> HaveConversion<TConversion, TComparer>() where TComparer : ValueComparer
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
Type Parameters
TConversion
The type to convert to and from or a type that inherits from ValueConverter.
TComparer
A type that inherits from ValueComparer.
HaveMaxLength(int)
Configures the maximum length of data that can be stored in this property. Maximum length can only be set on array properties (including string properties).
public virtual PropertiesConfigurationBuilder<TProperty> HaveMaxLength(int maxLength)
Parameters
maxLength
intThe maximum length of data allowed in the property.
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
HavePrecision(int)
Configures the precision of the property.
public virtual PropertiesConfigurationBuilder<TProperty> HavePrecision(int precision)
Parameters
precision
intThe precision of the property.
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.
HavePrecision(int, int)
Configures the precision and scale of the property.
public virtual PropertiesConfigurationBuilder<TProperty> HavePrecision(int precision, int scale)
Parameters
Returns
- PropertiesConfigurationBuilder<TProperty>
The same builder instance so that multiple configuration calls can be chained.