/// <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 SequenceFound( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, [NotNull] string sequenceName, [NotNull] string sequenceTypeName, bool cyclic, int increment, long start, long min, long max) { // No DiagnosticsSource events because these are purely design-time messages var definition = SqlServerResources.LogFoundSequence(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log( diagnostics, l => l.LogDebug( definition.EventId, null, definition.MessageFormat, sequenceName, sequenceTypeName, cyclic, increment, start, min, max)); } }
/// <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 ConflictingValueGenerationStrategiesWarning( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics, SqlServerValueGenerationStrategy sqlServerValueGenerationStrategy, [NotNull] string otherValueGenerationStrategy, [NotNull] IReadOnlyProperty property) { var definition = SqlServerResources.LogConflictingValueGenerationStrategies(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log( diagnostics, sqlServerValueGenerationStrategy.ToString(), otherValueGenerationStrategy, property.Name, property.DeclaringEntityType.DisplayName()); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = new ConflictingValueGenerationStrategiesEventData( definition, ConflictingValueGenerationStrategiesWarning, sqlServerValueGenerationStrategy, otherValueGenerationStrategy, property); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); } }
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 void Detects_nullable_byte_identity_column() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Dog>().Property(d => d.Id).ValueGeneratedNever(); modelBuilder.Entity <Dog>().Property <byte?>("Bite").UseSqlServerIdentityColumn(); VerifyWarning(SqlServerResources.LogByteIdentityColumn(new TestLogger <SqlServerLoggingDefinitions>()).GenerateMessage("Bite", nameof(Dog)), 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); }
public virtual void Detects_decimal_keys() { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Animal>() .Property <decimal>("Price").HasPrecision(18, 2); modelBuilder.Entity <Animal>().HasKey("Price"); VerifyWarning( SqlServerResources.LogDecimalTypeKey(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 MissingViewDefinitionRightsWarning( this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics) { var definition = SqlServerResources.LogMissingViewDefinitionRights(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 TableFound( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, [NotNull] string tableName) { var definition = SqlServerResources.LogFoundTable(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, tableName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 MissingSchemaWarning( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, [CanBeNull] string schemaName) { var definition = SqlServerResources.LogMissingSchema(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, schemaName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 DefaultSchemaFound( this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, string schemaName) { var definition = SqlServerResources.LogFoundDefaultSchema(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, schemaName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 ForeignKeyReferencesUnknownPrincipalTableWarning( this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, string?foreignKeyName, string?tableName) { var definition = SqlServerResources.LogPrincipalTableInformationNotFound(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, foreignKeyName, tableName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 ColumnWithoutTypeWarning( this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, string tableName, string columnName) { var definition = SqlServerResources.LogColumnWithoutType(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, tableName, columnName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 TypeAliasFound( this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, string typeAliasName, string systemTypeName) { var definition = SqlServerResources.LogFoundTypeAlias(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, typeAliasName, systemTypeName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 UniqueConstraintFound( this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, string uniqueConstraintName, string tableName) { var definition = SqlServerResources.LogFoundUniqueConstraint(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, uniqueConstraintName, tableName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 ReflexiveConstraintIgnored( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, [NotNull] string foreignKeyName, [NotNull] string tableName) { var definition = SqlServerResources.LogReflexiveConstraintIgnored(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, foreignKeyName, tableName); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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 ForeignKeyReferencesMissingPrincipalTableWarning( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, [CanBeNull] string foreignKeyName, [CanBeNull] string tableName, [CanBeNull] string principalTableName) { var definition = SqlServerResources.LogPrincipalTableNotInSelectionSet(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, foreignKeyName, tableName, principalTableName); } // No DiagnosticsSource events because these are purely design-time messages }
public void SqlServerValueGenerationStrategy_warns_when_setting_conflicting_value_generation_strategies( SqlServerValueGenerationStrategy sqlServerValueGenerationStrategy, string conflictingValueGenerationStrategy) { var modelBuilder = CreateConventionalModelBuilder(); var propertyBuilder = modelBuilder.Entity <Dog>().Property <int>("Id"); propertyBuilder.Metadata.SetValueGenerationStrategy(sqlServerValueGenerationStrategy); ConfigureProperty(propertyBuilder.Metadata, conflictingValueGenerationStrategy, "NEXT VALUE FOR [Id]"); VerifyWarning( SqlServerResources.LogConflictingValueGenerationStrategies(new TestLogger <SqlServerLoggingDefinitions>()) .GenerateMessage(sqlServerValueGenerationStrategy.ToString(), conflictingValueGenerationStrategy, "Id", nameof(Dog)), 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 ForeignKeyFound( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, [NotNull] string foreignKeyName, [NotNull] string tableName, [NotNull] string principalTableName, [NotNull] string onDeleteAction) { var definition = SqlServerResources.LogFoundForeignKey(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics, foreignKeyName, tableName, principalTableName, onDeleteAction); } // No DiagnosticsSource events because these are purely design-time messages }
public void SqlServerValueGenerationStrategy_warns_when_setting_conflicting_DefaultValue( SqlServerValueGenerationStrategy sqlServerValueGenerationStrategy) { var modelBuilder = CreateConventionalModelBuilder(); var propertyBuilder = modelBuilder.Entity <Dog>().Property <int>("Id"); propertyBuilder.Metadata.SetValueGenerationStrategy(sqlServerValueGenerationStrategy); ConfigureProperty(propertyBuilder.Metadata, "DefaultValue", "2"); VerifyWarnings(new[] { SqlServerResources.LogConflictingValueGenerationStrategies(new TestLogger <SqlServerLoggingDefinitions>()) .GenerateMessage(sqlServerValueGenerationStrategy.ToString(), "DefaultValue", "Id", nameof(Dog)), RelationalResources.LogKeyHasDefaultValue(new TestLogger <SqlServerLoggingDefinitions>()) .GenerateMessage("Id", nameof(Dog)) }, modelBuilder.Model); }
public virtual void SqlServerValueGeneration_conflicting_with_existing_ValueGeneration_strategy_throws() { var modelBuilder = CreateModelBuilder(); modelBuilder.Entity <Fred>() .Property(e => e.Id) .HasDefaultValueSql("2") .UseHiLo(); Assert.Equal( CoreStrings.WarningAsErrorTemplate( SqlServerEventId.ConflictingValueGenerationStrategiesWarning, SqlServerResources.LogConflictingValueGenerationStrategies( new TestLogger <SqlServerLoggingDefinitions>()) .GenerateMessage(SqlServerValueGenerationStrategy.SequenceHiLo.ToString(), "DefaultValueSql", "Id", nameof(Fred)), "SqlServerEventId.ConflictingValueGenerationStrategiesWarning"), Assert.Throws <InvalidOperationException>(() => Validate(modelBuilder)).Message); }
/// <summary> /// Logs for the <see cref="RelationalEventId.MultipleCollectionIncludeWarning" /> event. /// </summary> /// <param name="diagnostics"> The diagnostics logger to use. </param> public static void SavepointsDisabledBecauseOfMARS( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Database.Transaction> diagnostics) { var definition = SqlServerResources.LogSavepointsDisabledBecauseOfMARS(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log(diagnostics); } if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled)) { var eventData = new EventData( definition, (d, p) => ((EventDefinition)d).GenerateMessage()); diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled); } }
public void Detects_byte_identity_column(bool obsolete) { var modelBuilder = CreateConventionalModelBuilder(); modelBuilder.Entity <Dog>().Property(d => d.Id).ValueGeneratedNever(); if (obsolete) { #pragma warning disable 618 modelBuilder.Entity <Dog>().Property <byte>("Bite").UseSqlServerIdentityColumn(); #pragma warning restore 618 } else { modelBuilder.Entity <Dog>().Property <byte>("Bite").UseIdentityColumn(); } VerifyWarning(SqlServerResources.LogByteIdentityColumn(new TestLogger <SqlServerLoggingDefinitions>()).GenerateMessage("Bite", nameof(Dog)), modelBuilder.Model); }
public virtual void SqlServerValueGeneration_conflicting_with_existing_ValueGeneration_strategy_warns() { var modelBuilder = CreateModelBuilder(); modelBuilder.Entity <Fred>() .Property(e => e.Id) .HasDefaultValueSql("2") .UseHiLo(); // Assert - this does not throw Validate(modelBuilder); var logEntry = Fixture.ListLoggerFactory.Log.Single( l => l.Level == LogLevel.Warning && l.Id == SqlServerEventId.ConflictingValueGenerationStrategiesWarning); Assert.Equal(SqlServerResources.LogConflictingValueGenerationStrategies( new TestLogger <SqlServerLoggingDefinitions>()) .GenerateMessage(SqlServerValueGenerationStrategy.SequenceHiLo.ToString(), "DefaultValueSql", "Id", nameof(Fred)), logEntry.Message); }
/// <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 ColumnFound( [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics, [NotNull] string tableName, [NotNull] string columnName, int ordinal, [NotNull] string dataTypeName, int maxLength, int precision, int scale, bool nullable, bool identity, [CanBeNull] string defaultValue, [CanBeNull] string computedValue, bool?stored) { var definition = SqlServerResources.LogFoundColumn(diagnostics); if (diagnostics.ShouldLog(definition)) { definition.Log( diagnostics, l => l.LogDebug( definition.EventId, null, definition.MessageFormat, tableName, columnName, ordinal, dataTypeName, maxLength, precision, scale, nullable, identity, defaultValue, computedValue, stored)); } // No DiagnosticsSource events because these are purely design-time messages }
/// <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); } }