/// <summary> /// Validates the mapping/configuration of <see cref="bool"/> properties in the model. /// </summary> /// <param name="model"> The model to validate. </param> /// <param name="logger"> The logger to use. </param> protected virtual void ValidateBoolsWithDefaults([NotNull] IModel model, [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model.Validation> logger) { Check.NotNull(model, nameof(model)); foreach (var property in model.GetEntityTypes().SelectMany(e => e.GetDeclaredProperties())) { if (property.ClrType == typeof(bool) && property.ValueGenerated != ValueGenerated.Never && (IsNotNullAndFalse(property.GetDefaultValue()) || property.GetDefaultValueSql() != null)) { logger.BoolWithDefaultWarning(property); } } }
/// <summary> /// Validates the mapping/configuration of <see cref="bool" /> properties in the model. /// </summary> /// <param name="model"> The model to validate. </param> /// <param name="logger"> The logger to use. </param> protected virtual void ValidateBoolsWithDefaults( [NotNull] IModel model, [NotNull] IDiagnosticsLogger <DbLoggerCategory.Model.Validation> logger) { Check.NotNull(model, nameof(model)); foreach (var entityType in model.GetEntityTypes()) { foreach (var property in entityType.GetDeclaredProperties()) { if (property.ClrType != typeof(bool) || property.ValueGenerated == ValueGenerated.Never) { continue; } var table = property.DeclaringEntityType.GetTableName(); var schema = property.DeclaringEntityType.GetSchema(); if (IsNotNullAndFalse(property.GetDefaultValue(table, schema)) || property.GetDefaultValueSql(table, schema) != null) { logger.BoolWithDefaultWarning(property); } } }