public virtual void Detects_default_nullable_decimal_mapping() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Animal>().Property <decimal?>("Price"); VerifyWarning(SqlServerResources.LogDefaultDecimalTypeColumn(new TestLogger <SqlServerLoggingDefinitions>()).GenerateMessage("Price", nameof(Animal)), modelBuilder.Model); }
public virtual void Does_not_warn_if_decimal_column_has_precision_and_scale() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Animal>() .Property <decimal>("Price").HasPrecision(18, 2); VerifyLogDoesNotContain( SqlServerResources.LogDefaultDecimalTypeColumn(new TestLogger <SqlServerLoggingDefinitions>()) .GenerateMessage("Price", nameof(Animal)), modelBuilder.Model); }
public virtual void Warn_if_default_decimal_mapping_has_decimal_to_decimal_value_converter() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Animal>() .Property <decimal>("Price") .HasConversion(new TestDecimalToDecimalConverter()); VerifyWarning( SqlServerResources.LogDefaultDecimalTypeColumn(new TestLogger <SqlServerLoggingDefinitions>()) .GenerateMessage("Price", nameof(Animal)), modelBuilder.Model); }
/// <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 static void DecimalTypeDefaultWarning( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics, [NotNull] IProperty property) { var definition = SqlServerResources.LogDefaultDecimalTypeColumn(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, property.Name, property.DeclaringEntityType.DisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = new PropertyEventData( definition, DecimalTypeDefaultWarning, property); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); } }