Ejemplo n.º 1
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public static void SchemaConfiguredWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics,
            [NotNull] IEntityType entityType,
            [NotNull] string schema)
        {
            var definition = SqliteResources.LogSchemaConfigured(diagnostics);

            var warningBehavior = definition.GetLogBehavior(diagnostics);

            if (warningBehavior != WarningBehavior.Ignore)
            {
                definition.Log(
                    diagnostics,
                    warningBehavior,
                    entityType.DisplayName(), schema);
            }

            if (diagnostics.DiagnosticSource.IsEnabled(definition.EventId.Name))
            {
                diagnostics.DiagnosticSource.Write(
                    definition.EventId.Name,
                    new EntityTypeSchemaEventData(
                        definition,
                        SchemaConfiguredWarning,
                        entityType,
                        schema));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public static void SequenceConfiguredWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics,
            [NotNull] ISequence sequence)
        {
            var definition = SqliteResources.LogSequenceConfigured(diagnostics);

            var warningBehavior = definition.GetLogBehavior(diagnostics);

            if (warningBehavior != WarningBehavior.Ignore)
            {
                definition.Log(
                    diagnostics,
                    warningBehavior,
                    sequence.Name);
            }

            if (diagnostics.DiagnosticSource.IsEnabled(definition.EventId.Name))
            {
                diagnostics.DiagnosticSource.Write(
                    definition.EventId.Name,
                    new SequenceEventData(
                        definition,
                        SequenceConfiguredWarning,
                        sequence));
            }
        }
        public void Warn_missing_principal_column_for_foreign_key()
        {
            Test(
                @"
CREATE TABLE PrincipalTable (
    Id int PRIMARY KEY
);

CREATE TABLE DependentTable (
    Id int PRIMARY KEY,
    ForeignKeyId int,
    CONSTRAINT MYFK FOREIGN KEY (ForeignKeyId) REFERENCES PrincipalTable(ImaginaryId) ON DELETE CASCADE
);",
                Enumerable.Empty <string>(),
                Enumerable.Empty <string>(),
                dbModel =>
            {
                var(_, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning));

                Assert.Equal(SqliteResources.LogPrincipalColumnNotFound(new TestLogger <SqliteLoggingDefinitions>()).EventId, Id);
                Assert.Equal(
                    SqliteResources.LogPrincipalColumnNotFound(new TestLogger <SqliteLoggingDefinitions>()).GenerateMessage(
                        "0", "DependentTable", "ImaginaryId", "PrincipalTable"),
                    Message);
            },
                @"
DROP TABLE DependentTable;
DROP TABLE PrincipalTable;");
        }
Ejemplo n.º 4
0
        public void Detects_schemas()
        {
            var modelBuilder = CreateConventionalModelBuilder();

            modelBuilder.Entity <Animal>().ToTable("Animals", "pet").Ignore(a => a.FavoritePerson);

            VerifyWarning(SqliteResources.LogSchemaConfigured(new TestLogger <SqliteLoggingDefinitions>()).GenerateMessage("Animal", "pet"), modelBuilder.Model);
        }
Ejemplo n.º 5
0
        public void Detects_sequences()
        {
            var modelBuilder = CreateConventionalModelBuilder();

            modelBuilder.HasSequence("Fibonacci");

            VerifyWarning(SqliteResources.LogSequenceConfigured(new TestLogger <SqliteLoggingDefinitions>()).GenerateMessage("Fibonacci"), modelBuilder.Model);
        }
Ejemplo n.º 6
0
    /// <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 SchemasNotSupportedWarning(
        this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics)
    {
        var definition = SqliteResources.LogUsingSchemaSelectionsWarning(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics);
        }

        // No DiagnosticsSource events because these are purely design-time messages
    }
Ejemplo n.º 7
0
    /// <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 MissingTableWarning(
        this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
        string?tableName)
    {
        var definition = SqliteResources.LogMissingTable(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, tableName);
        }

        // No DiagnosticsSource events because these are purely design-time messages
    }
Ejemplo n.º 8
0
    /// <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 = SqliteResources.LogFoundUniqueConstraint(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, uniqueConstraintName, tableName);
        }

        // No DiagnosticsSource events because these are purely design-time messages
    }
Ejemplo n.º 9
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public static void SchemasNotSupportedWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics)
        {
            var definition = SqliteResources.LogUsingSchemaSelectionsWarning(diagnostics);

            var warningBehavior = definition.GetLogBehavior(diagnostics);

            if (warningBehavior != WarningBehavior.Ignore)
            {
                definition.Log(diagnostics, warningBehavior);
            }

            // No DiagnosticsSource events because these are purely design-time messages
        }
Ejemplo n.º 10
0
    /// <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 ForeignKeyReferencesMissingTableWarning(
        this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
        string?id,
        string?tableName,
        string?principalTableName)
    {
        var definition = SqliteResources.LogForeignKeyScaffoldErrorPrincipalTableNotFound(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, id, tableName, principalTableName);
        }

        // No DiagnosticsSource events because these are purely design-time messages
    }
        public void Warn_for_schema_filtering()
        {
            Test(
                "CREATE TABLE Everest ( id int );",
                Enumerable.Empty <string>(),
                new[] { "dbo" },
                dbModel =>
            {
                var(_, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning));

                Assert.Equal(SqliteResources.LogUsingSchemaSelectionsWarning(new TestLogger <SqliteLoggingDefinitions>()).EventId, Id);
                Assert.Equal(SqliteResources.LogUsingSchemaSelectionsWarning(new TestLogger <SqliteLoggingDefinitions>()).GenerateMessage(), Message);
            },
                "DROP TABLE Everest;");
        }
Ejemplo n.º 12
0
    public void Warn_missing_table()
    => Test(
        "CREATE TABLE Blank ( Id int );",
        new[] { "MyTable" },
        Enumerable.Empty <string>(),
        dbModel =>
    {
        Assert.Empty(dbModel.Tables);

        var(Level, Id, Message, _, _) = Assert.Single(Fixture.ListLoggerFactory.Log.Where(t => t.Level == LogLevel.Warning));

        Assert.Equal(SqliteResources.LogMissingTable(new TestLogger <SqliteLoggingDefinitions>()).EventId, Id);
        Assert.Equal(
            SqliteResources.LogMissingTable(new TestLogger <SqliteLoggingDefinitions>()).GenerateMessage("MyTable"), Message);
    },
        "DROP TABLE Blank;");
Ejemplo n.º 13
0
    /// <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(
        this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
        string?tableName,
        long id,
        string?principalTableName,
        string?deleteAction)
    {
        var definition = SqliteResources.LogFoundForeignKey(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, tableName, id, principalTableName, deleteAction);
        }

        // No DiagnosticsSource events because these are purely design-time messages
    }
Ejemplo n.º 14
0
    /// <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(
        this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
        string?tableName,
        string?columnName,
        string?dataTypeName,
        bool notNull,
        string?defaultValue)
    {
        var definition = SqliteResources.LogFoundColumn(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, tableName, columnName, dataTypeName, notNull, defaultValue);
        }

        // No DiagnosticsSource events because these are purely design-time messages
    }
Ejemplo n.º 15
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public static void MissingTableWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [CanBeNull] string tableName)
        {
            var definition = SqliteResources.LogMissingTable(diagnostics);

            var warningBehavior = definition.GetLogBehavior(diagnostics);

            if (warningBehavior != WarningBehavior.Ignore)
            {
                definition.Log(
                    diagnostics,
                    warningBehavior,
                    tableName);
            }

            // No DiagnosticsSource events because these are purely design-time messages
        }
Ejemplo n.º 16
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public static void ForeignKeyReferencesMissingTableWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [CanBeNull] string foreignKeyName)
        {
            var definition = SqliteResources.LogForeignKeyScaffoldErrorPrincipalTableNotFound(diagnostics);

            var warningBehavior = definition.GetLogBehavior(diagnostics);

            if (warningBehavior != WarningBehavior.Ignore)
            {
                definition.Log(
                    diagnostics,
                    warningBehavior,
                    foreignKeyName);
            }

            // No DiagnosticsSource events because these are purely design-time messages
        }
Ejemplo n.º 17
0
    /// <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 UnexpectedConnectionTypeWarning(
        this IDiagnosticsLogger <DbLoggerCategory.Infrastructure> diagnostics,
        Type connectionType)
    {
        var definition = SqliteResources.LogUnexpectedConnectionType(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, connectionType.ShortDisplayName());
        }

        if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
        {
            var eventData = new UnexpectedConnectionTypeEventData(
                definition,
                UnexpectedConnectionTypeWarning,
                connectionType);

            diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
        }
    }
Ejemplo n.º 18
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public static void ForeignKeyFound(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [CanBeNull] string tableName,
            long id,
            [CanBeNull] string principalTableName,
            [CanBeNull] string deleteAction)
        {
            var definition = SqliteResources.LogFoundForeignKey(diagnostics);

            var warningBehavior = definition.GetLogBehavior(diagnostics);

            if (warningBehavior != WarningBehavior.Ignore)
            {
                definition.Log(
                    diagnostics,
                    warningBehavior,
                    tableName, id, principalTableName, deleteAction);
            }

            // No DiagnosticsSource events because these are purely design-time messages
        }
Ejemplo n.º 19
0
    /// <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 SequenceConfiguredWarning(
        this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics,
        IReadOnlySequence sequence)
    {
        var definition = SqliteResources.LogSequenceConfigured(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, sequence.Name);
        }

        if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
        {
            var eventData = new SequenceEventData(
                definition,
                SequenceConfiguredWarning,
                sequence);

            diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
        }
    }
Ejemplo n.º 20
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public static void ColumnFound(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [CanBeNull] string tableName,
            [CanBeNull] string columnName,
            [CanBeNull] string dataTypeName,
            bool notNull,
            [CanBeNull] string defaultValue)
        {
            var definition = SqliteResources.LogFoundColumn(diagnostics);

            var warningBehavior = definition.GetLogBehavior(diagnostics);

            if (warningBehavior != WarningBehavior.Ignore)
            {
                definition.Log(
                    diagnostics,
                    warningBehavior,
                    tableName, columnName, dataTypeName, notNull, defaultValue);
            }

            // No DiagnosticsSource events because these are purely design-time messages
        }
Ejemplo n.º 21
0
    /// <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 TableRebuildPendingWarning(
        this IDiagnosticsLogger <DbLoggerCategory.Migrations> diagnostics,
        Type operationType,
        string tableName)
    {
        var definition = SqliteResources.LogTableRebuildPendingWarning(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, operationType.ShortDisplayName(), tableName);
        }

        if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
        {
            var eventData = new TableRebuildEventData(
                definition,
                TableRebuildPendingWarning,
                operationType,
                tableName);

            diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
        }
    }
Ejemplo n.º 22
0
    /// <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 SchemaConfiguredWarning(
        this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics,
        IEntityType entityType,
        string schema)
    {
        var definition = SqliteResources.LogSchemaConfigured(diagnostics);

        if (diagnostics.ShouldLog(definition))
        {
            definition.Log(diagnostics, entityType.DisplayName(), schema);
        }

        if (diagnostics.NeedsEventData(definition, out var diagnosticSourceEnabled, out var simpleLogEnabled))
        {
            var eventData = new EntityTypeSchemaEventData(
                definition,
                SchemaConfiguredWarning,
                entityType,
                schema);

            diagnostics.DispatchEventData(definition, eventData, diagnosticSourceEnabled, simpleLogEnabled);
        }
    }