/// <summary> /// Throws if there is conflicting store generation configuration for this property. /// </summary> /// <param name="property"> The property to check. </param> protected virtual void Validate([NotNull] IConventionProperty property) { if (property.GetDefaultValue() != null) { if (property.GetDefaultValueSql() != null) { throw new InvalidOperationException( RelationalStrings.ConflictingColumnServerGeneration("DefaultValue", property.Name, "DefaultValueSql")); } if (property.GetComputedColumnSql() != null) { throw new InvalidOperationException( RelationalStrings.ConflictingColumnServerGeneration("DefaultValue", property.Name, "ComputedColumnSql")); } } else if (property.GetDefaultValueSql() != null) { if (property.GetComputedColumnSql() != null) { throw new InvalidOperationException( RelationalStrings.ConflictingColumnServerGeneration("DefaultValueSql", property.Name, "ComputedColumnSql")); } } }
protected override void Validate(IConventionProperty property) { if (property.GetValueGenerationStrategyConfigurationSource() != null && property.GetValueGenerationStrategy() != JetValueGenerationStrategy.None) { if (property.GetDefaultValue() != null) { throw new InvalidOperationException( RelationalStrings.ConflictingColumnServerGeneration( "JetValueGenerationStrategy", property.Name, "DefaultValue")); } if (property.GetDefaultValueSql() != null) { throw new InvalidOperationException( RelationalStrings.ConflictingColumnServerGeneration( "JetValueGenerationStrategy", property.Name, "DefaultValueSql")); } if (property.GetComputedColumnSql() != null) { throw new InvalidOperationException( RelationalStrings.ConflictingColumnServerGeneration( "JetValueGenerationStrategy", property.Name, "ComputedColumnSql")); } } base.Validate(property); }
public static FbValueGenerationStrategy GetValueGenerationStrategy(this IConventionProperty property) { var annotation = property[FbAnnotationNames.ValueGenerationStrategy]; if (annotation != null) { return((FbValueGenerationStrategy)annotation); } if (property.ValueGenerated != ValueGenerated.OnAdd || property.GetDefaultValue() != null || property.GetDefaultValueSql() != null || property.GetComputedColumnSql() != null) { return(FbValueGenerationStrategy.None); } var modelStrategy = property.DeclaringEntityType.Model.GetValueGenerationStrategy(); if (modelStrategy == FbValueGenerationStrategy.SequenceTrigger && IsCompatibleSequenceTrigger(property)) { return(FbValueGenerationStrategy.SequenceTrigger); } if (modelStrategy == FbValueGenerationStrategy.IdentityColumn && IsCompatibleIdentityColumn(property)) { return(FbValueGenerationStrategy.IdentityColumn); } return(FbValueGenerationStrategy.None); }
/// <inheritdoc/> protected override void Validate(IConventionProperty property, StoreObjectIdentifier storeObject) { if (property.GetValueGenerationStrategyConfigurationSource() != null) { var generationStrategy = property.GetValueGenerationStrategy(storeObject); if (generationStrategy == SqlServerValueGenerationStrategy.None) { base.Validate(property, storeObject); return; } if (property.GetDefaultValue(storeObject) != null) { Dependencies.ValidationLogger.ConflictingValueGenerationStrategiesWarning( generationStrategy, "DefaultValue", property); } if (property.GetDefaultValueSql(storeObject) != null) { Dependencies.ValidationLogger.ConflictingValueGenerationStrategiesWarning( generationStrategy, "DefaultValueSql", property); } if (property.GetComputedColumnSql(storeObject) != null) { Dependencies.ValidationLogger.ConflictingValueGenerationStrategiesWarning( generationStrategy, "ComputedColumnSql", property); } } base.Validate(property, storeObject); }
/// <summary> /// Returns the store value generation strategy to set for the given property. /// </summary> /// <param name="property"> The property. </param> /// <returns> The store value generation strategy to set for the given property. </returns> public override ValueGenerated?GetValueGenerated(IConventionProperty property) { var valueGenerated = base.GetValueGenerated(property); if (valueGenerated != null) { return(valueGenerated); } return(property.GetComputedColumnSql() != null ? ValueGenerated.OnAddOrUpdate : property.GetDefaultValue() != null || property.GetDefaultValueSql() != null ? ValueGenerated.OnAdd : (ValueGenerated?)null); }