ValueGenerated ValueGenerated Enum

Indicates when a value for a property will be generated by the database. Even when a property is set to be generated by the database, EF may still attempt to save a specific value (rather than having one generated by the database) when an entity is added and a value is assigned, or the property is marked as modified for an existing entity.

Syntax

Declaration

public enum ValueGeneratedPublic Enum ValueGenerated

Fields

Never
Never

A value is never generated by the database.

OnAdd
OnAdd

A value is generated by the database when an entity is added. The most common scenario for this is generated primary key values.

OnAddOrUpdate
OnAddOrUpdate

A value is generated every time an entity is saved. This is typically used for scenarios such as row versions, timestamps, etc.

Details

Assembly

Microsoft.EntityFrameworkCore.dll