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.

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).

An example of temporary value generation is generating negative numbers for an integer primary key that are then replaced by positive numbers generated by the database when the entity is saved. An example of permanent value generation are client-generated values for a Guid primary key which are 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.

Applies to