From a1d83c4368c3ad2098e6f9067f0a37a4cb1290ce Mon Sep 17 00:00:00 2001 From: Neil Bostrom Date: Tue, 14 May 2019 22:33:52 +0100 Subject: [PATCH] Reintroduced UpdateConfigurationSource for CheckConstraint --- .../RelationalEntityTypeBuilderExtensions.cs | 4 ++-- .../Metadata/Internal/CheckConstraint.cs | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs b/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs index eced38f2ec3..2b9db4ecb90 100644 --- a/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalEntityTypeBuilderExtensions.cs @@ -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; } diff --git a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs index b46c55a825d..face3b93b7a 100644 --- a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs +++ b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs @@ -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. /// - public virtual ConfigurationSource ConfigurationSource { get; set; } + public virtual ConfigurationSource ConfigurationSource { get; private set; } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -143,11 +143,23 @@ public static bool RemoveCheckConstraint( /// public virtual ConfigurationSource GetConfigurationSource() => ConfigurationSource; + /// + /// 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. + /// + public virtual void UpdateConfigurationSource(ConfigurationSource configurationSource) + { + ConfigurationSource = configurationSource.Max(ConfigurationSource); + } + private static Dictionary GetAnnotationsDictionary(IEntityType entityType) { return (Dictionary)entityType[RelationalAnnotationNames.CheckConstraints]; } + /// IConventionEntityType IConventionCheckConstraint.EntityType => (IConventionEntityType)EntityType; } }