Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ValueGeneratedOnUpdateSometimes in Entity Framework Core

When I was configuring entities on a project, I came across ValueGeneratedOnUpdateSometimes on the PropertyBuilder. The description says

Configures a property to have a value generated under certain conditions when saving an existing entity

However there is no solid information about how to set "certain conditions" so the value gets generated.

Is there anybody who has some information about this?

like image 348
valkarin Avatar asked May 26 '26 10:05

valkarin


1 Answers

It is used for properties mapped to the same column with entity types sharing a table.

When you change the value of one of these properties and call SaveChanges the value for the other is "generated" by propagating the value from the first one.

like image 66
Andriy Svyryd Avatar answered May 28 '26 01:05

Andriy Svyryd