ValueGenerated Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Indicates when a value for a property will be generated by the database.
This enumeration supports a bitwise combination of its member values.
public enum ValueGenerated
[System.Flags]
public enum ValueGenerated
type ValueGenerated =
[<System.Flags>]
type ValueGenerated =
Public Enum ValueGenerated
- Inheritance
-
ValueGenerated
- Attributes
Fields
Name | Value | Description |
---|---|---|
Never | 0 | A value is never generated by the database. |
OnAdd | 1 | A value is generated by the database when an entity is first added to the database. The most common scenario for this is generated primary key values. |
OnUpdate | 2 | No value is generated when the entity is first added to the database, but a value will be read from the database whenever the entity is subsequently updated. |
OnAddOrUpdate | 3 | A value is read from the database when the entity is first added and whenever the entity is subsequently updated. This is typically used for computed columns and scenarios such as rowversions, timestamps, etc. |
OnUpdateSometimes | 4 | No value is generated when the entity is first added to the database, but a value will be read from the database under certain conditions when the entity is subsequently updated. |
Remarks
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. See PropertySaveBehavior for more details.
See Modeling entity types and relationships and See Value generation in EF Core for more information and examples.
Applies to
Entity Framework