ValueGenerator Class

Definition

Generates values for properties when an entity is added to a context.

public abstract class ValueGenerator
type ValueGenerator = class
Public MustInherit Class ValueGenerator
Inheritance
ValueGenerator
Derived

Remarks

See EF Core value generation for more information and examples.

Constructors

ValueGenerator()

Properties

GeneratesStableValues

Gets a value indicating whether the values generated are stable. That is, the value will always be the same for a given property in a given entity, and does not depend on what other values may have been generated previously. For example, discriminator values generated for a TPH hierarchy are stable. Stable values will never be marked as unknown.

GeneratesTemporaryValues

Gets a value indicating whether the values generated are temporary (i.e they should be replaced by database generated values when the entity is saved) or are permanent (i.e. the generated values should be saved to the database).

Methods

Next(EntityEntry)

Gets a value to be assigned to a property.

NextAsync(EntityEntry, CancellationToken)

Gets a value to be assigned to a property.

NextValue(EntityEntry)

Template method to be overridden by implementations to perform value generation.

NextValueAsync(EntityEntry, CancellationToken)

Template method to be overridden by implementations to perform value generation.

WithConverter(ValueConverter)

Wraps this ValueGenerator such that it processes values converted with the given ValueConverter.

Applies to