public virtual void AddValueGeneratedConfiguration( [NotNull] PropertyConfiguration propertyConfiguration) { Check.NotNull(propertyConfiguration, nameof(propertyConfiguration)); var valueGenerated = propertyConfiguration.Property.ValueGenerated; switch (valueGenerated) { case ValueGenerated.OnAdd: // If this property is the single integer primary key on the EntityType then // KeyConvention assumes ValueGeneratedOnAdd() so there is no need to add it. if (_keyConvention.FindValueGeneratedOnAddProperty( new List <Property> { (Property)propertyConfiguration.Property }, (EntityType)propertyConfiguration.EntityConfiguration.EntityType) == null) { propertyConfiguration.FluentApiConfigurations.Add( new FluentApiConfiguration(nameof(PropertyBuilder.ValueGeneratedOnAdd))); } break; case ValueGenerated.OnAddOrUpdate: propertyConfiguration.FluentApiConfigurations.Add( new FluentApiConfiguration(nameof(PropertyBuilder.ValueGeneratedOnAddOrUpdate))); break; } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void AddValueGeneratedConfiguration( [NotNull] PropertyConfiguration propertyConfiguration) { Check.NotNull(propertyConfiguration, nameof(propertyConfiguration)); if (!((Property)propertyConfiguration.Property).GetValueGeneratedConfigurationSource().HasValue) { return; } var valueGenerated = propertyConfiguration.Property.ValueGenerated; switch (valueGenerated) { case ValueGenerated.OnAdd: // If this property is the single integer primary key on the EntityType then // KeyConvention assumes ValueGeneratedOnAdd() so there is no need to add it. if (_keyConvention.FindValueGeneratedOnAddProperty( new List <Property> { (Property)propertyConfiguration.Property }, (EntityType)propertyConfiguration.EntityConfiguration.EntityType) == null && AnnotationProvider.For(propertyConfiguration.Property).DefaultValueSql == null) { propertyConfiguration.FluentApiConfigurations.Add( _configurationFactory.CreateFluentApiConfiguration( /* hasAttributeEquivalent */ false, nameof(PropertyBuilder.ValueGeneratedOnAdd))); } break; case ValueGenerated.OnAddOrUpdate: propertyConfiguration.FluentApiConfigurations.Add( _configurationFactory.CreateFluentApiConfiguration( /* hasAttributeEquivalent */ false, nameof(PropertyBuilder.ValueGeneratedOnAddOrUpdate))); break; case ValueGenerated.Never: propertyConfiguration.FluentApiConfigurations.Add( _configurationFactory.CreateFluentApiConfiguration( /* hasAttributeEquivalent */ false, nameof(PropertyBuilder.ValueGeneratedNever))); break; default: throw new ArgumentOutOfRangeException(); } }