Class ValueGenerator<TValue>
- Namespace
- Microsoft.EntityFrameworkCore.ValueGeneration
- Assembly
- Microsoft.EntityFrameworkCore.dll
Generates values for properties when an entity is added to a context.
public abstract class ValueGenerator<TValue> : ValueGenerator
Type Parameters
TValue
- Inheritance
-
ValueGenerator<TValue>
- Derived
- Inherited Members
Remarks
See EF Core value generation for more information and examples.
Constructors
ValueGenerator()
protected ValueGenerator()
Methods
Next(EntityEntry)
Template method to be overridden by implementations to perform value generation.
public abstract TValue Next(EntityEntry entry)
Parameters
entry
EntityEntryThe change tracking entry of the entity for which the value is being generated.
Returns
- TValue
The generated value.
Remarks
See EF Core value generation for more information and examples.
NextAsync(EntityEntry, CancellationToken)
Template method to be overridden by implementations to perform value generation.
public virtual ValueTask<TValue> NextAsync(EntityEntry entry, CancellationToken cancellationToken = default)
Parameters
entry
EntityEntryThe change tracking entry of the entity for which the value is being generated.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- ValueTask<TValue>
The generated value.
Remarks
See EF Core value generation for more information and examples.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
NextValue(EntityEntry)
Gets a value to be assigned to a property.
protected override object? NextValue(EntityEntry entry)
Parameters
entry
EntityEntryThe change tracking entry of the entity for which the value is being generated.
Returns
- object
The value to be assigned to a property.
Remarks
See EF Core value generation for more information and examples.
NextValueAsync(EntityEntry, CancellationToken)
Gets a value to be assigned to a property.
protected override ValueTask<object?> NextValueAsync(EntityEntry entry, CancellationToken cancellationToken = default)
Parameters
entry
EntityEntryThe change tracking entry of the entity for which the value is being generated.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
Remarks
See EF Core value generation for more information and examples.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.