Skip to content

Commit

Permalink
Allow conventions to update ValueGenerated
Browse files Browse the repository at this point in the history
Reacting to dotnet/efcore#7205

Note that this was done a long time ago in EFCore (2.0.0) but only
now discovered thanks to the internal analyzer warnings.
  • Loading branch information
roji committed Apr 20, 2019
1 parent c5dbd7b commit e87d198
Showing 1 changed file with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public NpgsqlPropertyBuilderAnnotations(
{
}

private InternalPropertyBuilder PropertyBuilder => ((Property)Property).Builder;

/// <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.
Expand Down Expand Up @@ -59,31 +57,19 @@ public NpgsqlPropertyBuilderAnnotations(
/// 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 new virtual bool DefaultValueSql([CanBeNull] string value)
{
PropertyBuilder.ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Convention);
return SetDefaultValueSql(value);
}
public new virtual bool DefaultValueSql([CanBeNull] string value) => SetDefaultValueSql(value);

/// <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 new virtual bool ComputedColumnSql([CanBeNull] string value)
{
PropertyBuilder.ValueGenerated(ValueGenerated.OnAddOrUpdate, ConfigurationSource.Convention);
return SetComputedColumnSql(value);
}
public new virtual bool ComputedColumnSql([CanBeNull] string value) => SetComputedColumnSql(value);

/// <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 new virtual bool DefaultValue([CanBeNull] object value)
{
PropertyBuilder.ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Convention);
return SetDefaultValue(value);
}
public new virtual bool DefaultValue([CanBeNull] object value) => SetDefaultValue(value);

/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
Expand Down Expand Up @@ -113,15 +99,12 @@ public NpgsqlPropertyBuilderAnnotations(
case NpgsqlValueGenerationStrategy.SerialColumn:
case NpgsqlValueGenerationStrategy.IdentityAlwaysColumn:
case NpgsqlValueGenerationStrategy.IdentityByDefaultColumn:
PropertyBuilder.ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Convention);
HiLoSequenceName(null);
HiLoSequenceSchema(null);
break;
case NpgsqlValueGenerationStrategy.SequenceHiLo:
PropertyBuilder.ValueGenerated(ValueGenerated.OnAdd, ConfigurationSource.Convention);
break;
case null:
PropertyBuilder.ValueGenerated(ValueGenerated.Never, ConfigurationSource.Convention);
HiLoSequenceName(null);
HiLoSequenceSchema(null);
break;
Expand Down

0 comments on commit e87d198

Please sign in to comment.