Skip to content

Commit

Permalink
Reintroduced UpdateConfigurationSource for CheckConstraint
Browse files Browse the repository at this point in the history
  • Loading branch information
Muppets committed May 14, 2019
1 parent 58597d8 commit a1d83c4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,8 @@ public static IConventionEntityTypeBuilder HasCheckConstraint(
{
if (constraint.Sql == sql)
{
((CheckConstraint)constraint).ConfigurationSource =
fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention;
((CheckConstraint)constraint).UpdateConfigurationSource(
fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
return entityTypeBuilder;
}

Expand Down
14 changes: 13 additions & 1 deletion src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static bool RemoveCheckConstraint(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual ConfigurationSource ConfigurationSource { get; set; }
public virtual ConfigurationSource ConfigurationSource { get; private set; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -143,11 +143,23 @@ public static bool RemoveCheckConstraint(
/// </summary>
public virtual ConfigurationSource GetConfigurationSource() => ConfigurationSource;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void UpdateConfigurationSource(ConfigurationSource configurationSource)
{
ConfigurationSource = configurationSource.Max(ConfigurationSource);
}

private static Dictionary<string, CheckConstraint> GetAnnotationsDictionary(IEntityType entityType)
{
return (Dictionary<string, CheckConstraint>)entityType[RelationalAnnotationNames.CheckConstraints];
}

/// <inheritdoc />
IConventionEntityType IConventionCheckConstraint.EntityType => (IConventionEntityType)EntityType;
}
}

0 comments on commit a1d83c4

Please sign in to comment.