concept value generator in category entity framework
appears as: value generator, The value generator

This is an excerpt from Manning's book Entity Framework Core in Action.
Listing 8.8 A value generator producing a unique string with the
Namepropertypublic class OrderIdValueGenerator : ValueGenerator<string> #1 { public override bool GeneratesTemporaryValues => false; #2 public override string Next #3 (EntityEntry entry) { var name = entry. #4 Property(nameof(DefaultEntity.Name)) #5 .CurrentValue; var uniqueNum = DateTime.UtcNow.Ticks; return $"{name}-{uniqueNum}"; #6 } } #1 Your value generator needs to inherit from EF Core’s ValueGenerator<T>. #2 Set this to false if you want your value to be written to the database. #3 Called when you Add the entity to the DbContext. #4 Gives you access to the entity that the value generator creates a value for. You can access its properties, etc. #5 Selects the property called Name and gets its current value #6 You need to return a value of the type you’ve defined as T in the inherited ValueGenerator<T>.This is the code to configure the use of a value generator: