Class PropertiesConfigurationBuilder
- Namespace
- Microsoft.EntityFrameworkCore.Metadata.Builders
- Assembly
- Microsoft.EntityFrameworkCore.dll
Provides a simple API surface for setting property defaults before conventions run.
public class PropertiesConfigurationBuilder
- Inheritance
-
PropertiesConfigurationBuilder
- Derived
- 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
Properties
Configuration
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]
protected virtual PropertyConfiguration Configuration { get; }
Property Value
Methods
AreUnicode(bool)
Configures whether the property as capable of persisting unicode characters. Can only be set on string properties.
public virtual PropertiesConfigurationBuilder AreUnicode(bool unicode = true)
Parameters
unicode
boolA value indicating whether the property can contain unicode characters.
Returns
- PropertiesConfigurationBuilder
The same builder instance so that multiple configuration calls can be chained.
HaveAnnotation(string, object)
Adds or updates an annotation on the property.
public virtual PropertiesConfigurationBuilder 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
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 HaveConversion(Type conversionType)
Parameters
conversionType
TypeThe type to convert to and from or a type that inherits from ValueConverter.
Returns
- PropertiesConfigurationBuilder
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 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
The same builder instance so that multiple configuration calls can be chained.
HaveConversion(Type, 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 HaveConversion(Type conversionType, Type? comparerType, Type? providerComparerType)
Parameters
conversionType
TypeThe type to convert to and from or a type that inherits from ValueConverter.
comparerType
TypeA type that inherits from ValueComparer.
providerComparerType
TypeA type that inherits from ValueComparer to use for the provider values.
Returns
- PropertiesConfigurationBuilder
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 HaveConversion<TConversion>()
Returns
- PropertiesConfigurationBuilder
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 HaveConversion<TConversion, TComparer>() where TComparer : ValueComparer
Returns
- PropertiesConfigurationBuilder
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.
HaveConversion<TConversion, TComparer, TProviderComparer>()
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 HaveConversion<TConversion, TComparer, TProviderComparer>() where TComparer : ValueComparer
Returns
- PropertiesConfigurationBuilder
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.
TProviderComparer
A type that inherits from ValueComparer to use for the provider values.
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 HaveMaxLength(int maxLength)
Parameters
maxLength
intThe maximum length of data allowed in the property.
Returns
- PropertiesConfigurationBuilder
The same builder instance so that multiple configuration calls can be chained.
HavePrecision(int)
Configures the precision of the property.
public virtual PropertiesConfigurationBuilder HavePrecision(int precision)
Parameters
precision
intThe precision of the property.
Returns
- PropertiesConfigurationBuilder
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 HavePrecision(int precision, int scale)
Parameters
Returns
- PropertiesConfigurationBuilder
The same builder instance so that multiple configuration calls can be chained.
HaveSentinel(object?)
Configures the value that will be used to determine if the property has been set or not. If the property is set to the sentinel value, then it is considered not set. By default, the sentinel value is the CLR default value for the type of the property.
public virtual PropertiesConfigurationBuilder HaveSentinel(object? sentinel)
Parameters
sentinel
objectThe sentinel value.
Returns
- PropertiesConfigurationBuilder
The same builder instance so that multiple configuration calls can be chained.