diff --git a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs index 23420f06c1b..7981a6fe119 100644 --- a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs +++ b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs @@ -65,7 +65,7 @@ private enum Id QueryClientEvaluationWarning = CoreEventId.RelationalBaseId + 500, QueryPossibleUnintendedUseOfEqualsWarning, QueryPossibleExceptionWithAggregateOperatorWarning, - ValueConversionSqlLiteralWarning, + ValueConversionSqlLiteralWarning, // This warning has been removed. // Model validation events ModelValidationKeyDefaultValueWarning = CoreEventId.RelationalBaseId + 600, @@ -463,16 +463,6 @@ private enum Id /// public static readonly EventId QueryPossibleExceptionWithAggregateOperatorWarning = MakeQueryId(Id.QueryPossibleExceptionWithAggregateOperatorWarning); - /// - /// - /// A SQL literal is being generated for a value that is using a value conversion. - /// - /// - /// This event is in the category. - /// - /// - public static readonly EventId ValueConversionSqlLiteralWarning = MakeQueryId(Id.ValueConversionSqlLiteralWarning); - private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + "."; private static EventId MakeValidationId(Id id) => new EventId((int)id, _validationPrefix + id); diff --git a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs index 4cd9c6a29ea..2e6021a739f 100644 --- a/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs +++ b/src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs @@ -1363,48 +1363,6 @@ public static void QueryPossibleExceptionWithAggregateOperatorWarning( } } - /// - /// Logs for the event. - /// - /// The diagnostics logger to use. - /// The CLR type. - /// The value converter. - public static void ValueConversionSqlLiteralWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [NotNull] Type mappingClrType, - [NotNull] ValueConverter valueConverter) - { - var definition = RelationalResources.LogValueConversionSqlLiteralWarning(diagnostics); - - var warningBehavior = definition.GetLogBehavior(diagnostics); - if (warningBehavior != WarningBehavior.Ignore) - { - definition.Log( - diagnostics, - warningBehavior, - mappingClrType.ShortDisplayName(), - valueConverter.GetType().ShortDisplayName()); - } - - if (diagnostics.DiagnosticSource.IsEnabled(definition.EventId.Name)) - { - diagnostics.DiagnosticSource.Write( - definition.EventId.Name, - new ValueConverterEventData( - definition, - ValueConversionSqlLiteral, - mappingClrType, - valueConverter)); - } - } - - private static string ValueConversionSqlLiteral(EventDefinitionBase definition, EventData payload) - { - var d = (EventDefinition)definition; - var p = (ValueConverterEventData)payload; - return d.GenerateMessage(p.MappingClrType.ShortDisplayName(), p.ValueConverter.GetType().ShortDisplayName()); - } - /// /// Logs for the event. /// diff --git a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs index 28e54bded68..c7f86467f2a 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs +++ b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs @@ -1409,29 +1409,5 @@ public static EventDefinition LogMigrationAttributeMissingWarning([NotNu return (EventDefinition)definition; } - - /// - /// A SQL parameter or literal was generated for the type '{type}' using the ValueConverter '{valueConverter}'. Review the generated SQL for correctness and consider evaluating the target expression in-memory instead. - /// - public static EventDefinition LogValueConversionSqlLiteralWarning([NotNull] IDiagnosticsLogger logger) - { - var definition = ((RelationalLoggingDefinitions)logger.Definitions).LogValueConversionSqlLiteralWarning; - if (definition == null) - { - definition = LazyInitializer.EnsureInitialized( - ref ((RelationalLoggingDefinitions)logger.Definitions).LogValueConversionSqlLiteralWarning, - () => new EventDefinition( - logger.Options, - RelationalEventId.ValueConversionSqlLiteralWarning, - LogLevel.Warning, - "RelationalEventId.ValueConversionSqlLiteralWarning", - level => LoggerMessage.Define( - level, - RelationalEventId.ValueConversionSqlLiteralWarning, - _resourceManager.GetString("LogValueConversionSqlLiteralWarning")))); - } - - return (EventDefinition)definition; - } } } diff --git a/src/EFCore.Relational/Properties/RelationalStrings.resx b/src/EFCore.Relational/Properties/RelationalStrings.resx index 14cfdd8979d..16cf0de54c2 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.resx +++ b/src/EFCore.Relational/Properties/RelationalStrings.resx @@ -445,10 +445,6 @@ A MigrationAttribute isn't specified on the '{class}' class. Warning RelationalEventId.MigrationAttributeMissingWarning string - - A SQL parameter or literal was generated for the type '{type}' using the ValueConverter '{valueConverter}'. Review the generated SQL for correctness and consider evaluating the target expression in-memory instead. - Warning RelationalEventId.ValueConversionSqlLiteralWarning object object - The entity type '{entityType}' cannot be mapped to a table because it is derived from '{baseType}'. Only base entity types can be mapped to a table. diff --git a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs index 68e1e7e0cde..3520f95bfdf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/ConvertToProviderTypesSqlServerTest.cs @@ -23,22 +23,6 @@ public ConvertToProviderTypesSqlServerTest(ConvertToProviderTypesSqlServerFixtur { } - [ConditionalFact(Skip = "Issue#15312")] - public virtual void Warning_when_suspicious_conversion_in_sql() - { - using (var context = CreateContext()) - { - Assert.Contains( - RelationalResources.LogValueConversionSqlLiteralWarning(new TestLogger()) - .GenerateMessage( - typeof(decimal).ShortDisplayName(), - new NumberToBytesConverter().GetType().ShortDisplayName()), - Assert.Throws( - () => - context.Set().Where(b => b.TestDecimal > 123.0m).ToList()).Message); - } - } - [ConditionalFact] public virtual void Columns_have_expected_data_types() {