diff --git a/src/EFCore.Design/Diagnostics/DesignEventId.cs b/src/EFCore.Design/Diagnostics/DesignEventId.cs deleted file mode 100644 index 589721bec17..00000000000 --- a/src/EFCore.Design/Diagnostics/DesignEventId.cs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Diagnostics; -using Microsoft.Extensions.Logging; - -namespace Microsoft.EntityFrameworkCore.Diagnostics -{ - /// - /// - /// Event IDs for design events that correspond to messages logged to an - /// and events sent to a . - /// - /// - /// These IDs are also used with to configure the - /// behavior of warnings. - /// - /// - public static class DesignEventId - { - // Warning: These values must not change between releases. - // Only add new values to the end of sections, never in the middle. - // Try to use naming and be consistent with existing names. - private enum Id - { - // Scaffolding warning events - SequenceTypeNotSupportedWarning = CoreEventId.CoreDesignBaseId, - UnableToGenerateEntityTypeWarning, - ColumnTypeNotMappedWarning, - MissingPrimaryKeyWarning, - PrimaryKeyColumnsNotMappedWarning, - ForeignKeyReferencesNotMappedTableWarning, - ForeignKeyReferencesMissingPrincipalKeyWarning, - ForeignKeyPrincipalEndContainsNullableColumnsWarning, - NonNullableBoooleanColumnHasDefaultConstraintWarning - } - - private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + "."; - private static EventId MakeScaffoldingId(Id id) => new EventId((int)id, _scaffoldingPrefix + id); - - /// - /// The database has a sequence of a type that is not supported. - /// This event is in the category. - /// - public static readonly EventId SequenceTypeNotSupportedWarning = MakeScaffoldingId(Id.SequenceTypeNotSupportedWarning); - - /// - /// An entity type could not be generated. - /// This event is in the category. - /// - public static readonly EventId UnableToGenerateEntityTypeWarning = MakeScaffoldingId(Id.UnableToGenerateEntityTypeWarning); - - /// - /// A column type could not be mapped. - /// This event is in the category. - /// - public static readonly EventId ColumnTypeNotMappedWarning = MakeScaffoldingId(Id.ColumnTypeNotMappedWarning); - - /// - /// A table is missing a primary key. - /// This event is in the category. - /// - public static readonly EventId MissingPrimaryKeyWarning = MakeScaffoldingId(Id.MissingPrimaryKeyWarning); - - /// - /// Columns in a primary key were not mapped. - /// This event is in the category. - /// - public static readonly EventId PrimaryKeyColumnsNotMappedWarning = MakeScaffoldingId(Id.PrimaryKeyColumnsNotMappedWarning); - - /// - /// A foreign key references a table that was not mapped. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyReferencesNotMappedTableWarning = MakeScaffoldingId(Id.ForeignKeyReferencesNotMappedTableWarning); - - /// - /// A foreign key references missing prinicpal key columns. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyReferencesMissingPrincipalKeyWarning = MakeScaffoldingId(Id.ForeignKeyReferencesMissingPrincipalKeyWarning); - - /// - /// A principal key contains nullable columns. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyPrincipalEndContainsNullableColumnsWarning = MakeScaffoldingId(Id.ForeignKeyPrincipalEndContainsNullableColumnsWarning); - - /// - /// A column would be mapped to a bool type, is non-nullable and has a default constraint. - /// This event is in the category. - /// - public static readonly EventId NonNullableBoooleanColumnHasDefaultConstraintWarning = MakeScaffoldingId(Id.NonNullableBoooleanColumnHasDefaultConstraintWarning); - } -} diff --git a/src/EFCore.Design/Internal/DesignLoggerExtensions.cs b/src/EFCore.Design/Internal/DesignLoggerExtensions.cs deleted file mode 100644 index cac993e82d2..00000000000 --- a/src/EFCore.Design/Internal/DesignLoggerExtensions.cs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; - -namespace Microsoft.EntityFrameworkCore.Internal -{ - /// - /// 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. - /// - public static class DesignLoggerExtensions - { - /// - /// 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. - /// - public static void SequenceTypeNotSupportedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string sequenceName, - [CanBeNull] string dataTypeName) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogBadSequenceType.Log(diagnostics, sequenceName, dataTypeName); - - /// - /// 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. - /// - public static void UnableToGenerateEntityTypeWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogUnableToGenerateEntityType.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void ColumnTypeNotMappedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string columnName, - [CanBeNull] string dataTypeName) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogCannotFindTypeMappingForColumn.Log(diagnostics, columnName, dataTypeName); - - /// - /// 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. - /// - public static void MissingPrimaryKeyWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogMissingPrimaryKey.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void PrimaryKeyColumnsNotMappedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName, - [NotNull] IList unmappedColumnNames) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogPrimaryKeyErrorPropertyNotFound.Log( - diagnostics, - tableName, - string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumnNames)); - - /// - /// 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. - /// - public static void ForeignKeyReferencesNotMappedTableWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName, - [NotNull] string principalTableName) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogForeignKeyScaffoldErrorPrincipalTableScaffoldingError.Log(diagnostics, foreignKeyName, principalTableName); - - /// - /// 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. - /// - public static void ForeignKeyReferencesMissingPrincipalKeyWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName, - [CanBeNull] string principalEntityTypeName, - [NotNull] IList principalColumnNames) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogForeignKeyScaffoldErrorPrincipalKeyNotFound.Log( - diagnostics, - foreignKeyName, - string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, principalColumnNames), - principalEntityTypeName); - - /// - /// 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. - /// - public static void ForeignKeyPrincipalEndContainsNullableColumnsWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName, - [CanBeNull] string indexName, - [CanBeNull] IList nullablePropertyNames) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogForeignKeyPrincipalEndContainsNullableColumns.Log( - diagnostics, - foreignKeyName, - indexName, - nullablePropertyNames.Aggregate((a, b) => a + "," + b)); - - /// - /// 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. - /// - public static void NonNullableBoooleanColumnHasDefaultConstraintWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string columnName) - // No DiagnosticsSource events because these are purely design-time messages - => DesignStrings.LogNonNullableBoooleanColumnHasDefaultConstraint.Log( - diagnostics, - columnName); - } -} diff --git a/src/EFCore.Design/Properties/DesignStrings.Designer.cs b/src/EFCore.Design/Properties/DesignStrings.Designer.cs index f64ab4f247b..dcc75502665 100644 --- a/src/EFCore.Design/Properties/DesignStrings.Designer.cs +++ b/src/EFCore.Design/Properties/DesignStrings.Designer.cs @@ -88,12 +88,6 @@ public static string DatabaseDropped([CanBeNull] object name) GetString("DatabaseDropped", nameof(name)), name); - /// - /// Cancelled. - /// - public static string Cancelled - => GetString("Cancelled"); - /// /// A manual migration deletion was detected. /// @@ -188,14 +182,6 @@ public static string CannotFindRuntimeProviderAssembly([CanBeNull] object assemb public static string DestructiveOperation => GetString("DestructiveOperation"); - /// - /// Reusing directory of file '{file}'. - /// - public static string ReusingDirectory([CanBeNull] object file) - => string.Format( - GetString("ReusingDirectory", nameof(file)), - file); - /// /// Writing migration to '{file}'. /// @@ -320,14 +306,6 @@ public static string NotExistDatabase([CanBeNull] object name) GetString("NotExistDatabase", nameof(name)), name); - /// - /// Could not serialize {obj} [{name}] - /// - public static string CouldNotSerialize([CanBeNull] object obj, [CanBeNull] object name) - => string.Format( - GetString("CouldNotSerialize", nameof(obj), nameof(name)), - obj, name); - /// /// Using environment '{environment}'. /// @@ -479,110 +457,104 @@ public static string ExistingFiles([CanBeNull] object outputDirectoryName, [CanB /// /// Could not find type mapping for column '{columnName}' with data type '{dateType}'. Skipping column. /// - public static readonly EventDefinition LogCannotFindTypeMappingForColumn - = new EventDefinition( - DesignEventId.ColumnTypeNotMappedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.ColumnTypeNotMappedWarning, - _resourceManager.GetString("LogCannotFindTypeMappingForColumn"))); + public static string CannotFindTypeMappingForColumn([CanBeNull] object columnName, [CanBeNull] object dateType) + => string.Format( + GetString("CannotFindTypeMappingForColumn", nameof(columnName), nameof(dateType)), + columnName, dateType); /// /// Could not scaffold the foreign key '{foreignKeyName}'. A key for '{columnsList}' was not found in the principal entity type '{principalEntityType}'. /// - public static readonly EventDefinition LogForeignKeyScaffoldErrorPrincipalKeyNotFound - = new EventDefinition( - DesignEventId.ForeignKeyReferencesMissingPrincipalKeyWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.ForeignKeyReferencesMissingPrincipalKeyWarning, - _resourceManager.GetString("LogForeignKeyScaffoldErrorPrincipalKeyNotFound"))); + public static string ForeignKeyScaffoldErrorPrincipalKeyNotFound([CanBeNull] object foreignKeyName, [CanBeNull] object columnsList, [CanBeNull] object principalEntityType) + => string.Format( + GetString("ForeignKeyScaffoldErrorPrincipalKeyNotFound", nameof(foreignKeyName), nameof(columnsList), nameof(principalEntityType)), + foreignKeyName, columnsList, principalEntityType); /// /// Could not scaffold the foreign key '{foreignKeyName}'. The referenced table '{principaltableName}' could not be scaffolded. /// - public static readonly EventDefinition LogForeignKeyScaffoldErrorPrincipalTableScaffoldingError - = new EventDefinition( - DesignEventId.ForeignKeyReferencesNotMappedTableWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.ForeignKeyReferencesNotMappedTableWarning, - _resourceManager.GetString("LogForeignKeyScaffoldErrorPrincipalTableScaffoldingError"))); + public static string ForeignKeyScaffoldErrorPrincipalTableScaffoldingError([CanBeNull] object foreignKeyName, [CanBeNull] object principaltableName) + => string.Format( + GetString("ForeignKeyScaffoldErrorPrincipalTableScaffoldingError", nameof(foreignKeyName), nameof(principaltableName)), + foreignKeyName, principaltableName); /// /// Could not scaffold the primary key for '{tableName}'. The following columns in the primary key could not be scaffolded: {columnNames}. /// - public static readonly EventDefinition LogPrimaryKeyErrorPropertyNotFound - = new EventDefinition( - DesignEventId.PrimaryKeyColumnsNotMappedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.PrimaryKeyColumnsNotMappedWarning, - _resourceManager.GetString("LogPrimaryKeyErrorPropertyNotFound"))); + public static string PrimaryKeyErrorPropertyNotFound([CanBeNull] object tableName, [CanBeNull] object columnNames) + => string.Format( + GetString("PrimaryKeyErrorPropertyNotFound", nameof(tableName), nameof(columnNames)), + tableName, columnNames); /// /// Unable to identify the primary key for table '{tableName}'. /// - public static readonly EventDefinition LogMissingPrimaryKey - = new EventDefinition( - DesignEventId.MissingPrimaryKeyWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.MissingPrimaryKeyWarning, - _resourceManager.GetString("LogMissingPrimaryKey"))); + public static string MissingPrimaryKey([CanBeNull] object tableName) + => string.Format( + GetString("MissingPrimaryKey", nameof(tableName)), + tableName); /// /// Unable to generate entity type for table '{tableName}'. /// - public static readonly EventDefinition LogUnableToGenerateEntityType - = new EventDefinition( - DesignEventId.UnableToGenerateEntityTypeWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.UnableToGenerateEntityTypeWarning, - _resourceManager.GetString("LogUnableToGenerateEntityType"))); + public static string UnableToGenerateEntityType([CanBeNull] object tableName) + => string.Format( + GetString("UnableToGenerateEntityType", nameof(tableName)), + tableName); /// /// For sequence '{sequenceName}'. Unable to scaffold because it uses an unsupported type: '{typeName}'. /// - public static readonly EventDefinition LogBadSequenceType - = new EventDefinition( - DesignEventId.SequenceTypeNotSupportedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.SequenceTypeNotSupportedWarning, - _resourceManager.GetString("LogBadSequenceType"))); + public static string BadSequenceType([CanBeNull] object sequenceName, [CanBeNull] object typeName) + => string.Format( + GetString("BadSequenceType", nameof(sequenceName), nameof(typeName)), + sequenceName, typeName); /// /// The principal end of the foreign key '{foreignKeyName}' is supported by the unique index '{indexName}' and contains the following nullable columns '{columnNames}'. Entity Framework requires the properties representing those columns to be non-nullable. /// - public static readonly EventDefinition LogForeignKeyPrincipalEndContainsNullableColumns - = new EventDefinition( - DesignEventId.ForeignKeyPrincipalEndContainsNullableColumnsWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.ForeignKeyPrincipalEndContainsNullableColumnsWarning, - _resourceManager.GetString("LogForeignKeyPrincipalEndContainsNullableColumns"))); + public static string ForeignKeyPrincipalEndContainsNullableColumns([CanBeNull] object foreignKeyName, [CanBeNull] object indexName, [CanBeNull] object columnNames) + => string.Format( + GetString("ForeignKeyPrincipalEndContainsNullableColumns", nameof(foreignKeyName), nameof(indexName), nameof(columnNames)), + foreignKeyName, indexName, columnNames); /// /// The column '{columnName}' would normally be mapped to a non-nullable bool property, but it has a default constraint. Such a column is mapped to a nullable bool property to allow a difference between setting the property to false and invoking the default constraint. See https://go.microsoft.com/fwlink/?linkid=851278 for details. /// - public static readonly EventDefinition LogNonNullableBoooleanColumnHasDefaultConstraint - = new EventDefinition( - DesignEventId.NonNullableBoooleanColumnHasDefaultConstraintWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - DesignEventId.NonNullableBoooleanColumnHasDefaultConstraintWarning, - _resourceManager.GetString("LogNonNullableBoooleanColumnHasDefaultConstraint"))); + public static string NonNullableBoooleanColumnHasDefaultConstraint([CanBeNull] object columnName) + => string.Format( + GetString("NonNullableBoooleanColumnHasDefaultConstraint", nameof(columnName)), + columnName); + + /// + /// Could not scaffold the foreign key '{foreignKeyName}'. The referenced table could not be found. This most likely occurred because the referenced table was excluded from scaffolding. + /// + public static string ForeignKeyScaffoldErrorPrincipalTableNotFound([CanBeNull] object foreignKeyName) + => string.Format( + GetString("ForeignKeyScaffoldErrorPrincipalTableNotFound", nameof(foreignKeyName)), + foreignKeyName); + + /// + /// Could not scaffold the foreign key '{foreignKeyName}'. The following columns in the foreign key could not be scaffolded: {columnNames}. + /// + public static string ForeignKeyScaffoldErrorPropertyNotFound([CanBeNull] object foreignKeyName, [CanBeNull] object columnNames) + => string.Format( + GetString("ForeignKeyScaffoldErrorPropertyNotFound", nameof(foreignKeyName), nameof(columnNames)), + foreignKeyName, columnNames); + + /// + /// Unable to scaffold the index '{indexName}'. The following columns could not be scaffolded: {columnNames}. + /// + public static string UnableToScaffoldIndexMissingProperty([CanBeNull] object indexName, [CanBeNull] object columnNames) + => string.Format( + GetString("UnableToScaffoldIndexMissingProperty", nameof(indexName), nameof(columnNames)), + indexName, columnNames); + + /// + /// Sequence name cannot be null or empty. Entity Framework cannot model a sequence that does not have a name. + /// + public static string SequencesRequireName + => GetString("SequencesRequireName"); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/EFCore.Design/Properties/DesignStrings.resx b/src/EFCore.Design/Properties/DesignStrings.resx index 55bea4416b9..cc3dbcf7d93 100644 --- a/src/EFCore.Design/Properties/DesignStrings.resx +++ b/src/EFCore.Design/Properties/DesignStrings.resx @@ -144,9 +144,6 @@ Successfully dropped database '{name}'. - - Cancelled. - A manual migration deletion was detected. @@ -186,9 +183,6 @@ An operation was scaffolded that may result in the loss of data. Please review the migration for accuracy. - - Reusing directory of file '{file}'. - Writing migration to '{file}'. @@ -240,9 +234,6 @@ Change your target project to the migrations project by using the Package Manage Database '{name}' did not exist, no action was taken. - - Could not serialize {obj} [{name}] - Using environment '{environment}'. @@ -303,40 +294,43 @@ Change your target project to the migrations project by using the Package Manage The following file(s) already exist in directory {outputDirectoryName}: {existingFiles}. Use the Force flag to overwrite these files. - + Could not find type mapping for column '{columnName}' with data type '{dateType}'. Skipping column. - Warning DesignEventId.ColumnTypeNotMappedWarning string string - + Could not scaffold the foreign key '{foreignKeyName}'. A key for '{columnsList}' was not found in the principal entity type '{principalEntityType}'. - Warning DesignEventId.ForeignKeyReferencesMissingPrincipalKeyWarning string string string - + Could not scaffold the foreign key '{foreignKeyName}'. The referenced table '{principaltableName}' could not be scaffolded. - Warning DesignEventId.ForeignKeyReferencesNotMappedTableWarning string string - + Could not scaffold the primary key for '{tableName}'. The following columns in the primary key could not be scaffolded: {columnNames}. - Warning DesignEventId.PrimaryKeyColumnsNotMappedWarning string string - + Unable to identify the primary key for table '{tableName}'. - Warning DesignEventId.MissingPrimaryKeyWarning string - + Unable to generate entity type for table '{tableName}'. - Warning DesignEventId.UnableToGenerateEntityTypeWarning string - + For sequence '{sequenceName}'. Unable to scaffold because it uses an unsupported type: '{typeName}'. - Warning DesignEventId.SequenceTypeNotSupportedWarning string string - + The principal end of the foreign key '{foreignKeyName}' is supported by the unique index '{indexName}' and contains the following nullable columns '{columnNames}'. Entity Framework requires the properties representing those columns to be non-nullable. - Warning DesignEventId.ForeignKeyPrincipalEndContainsNullableColumnsWarning string string string - + The column '{columnName}' would normally be mapped to a non-nullable bool property, but it has a default constraint. Such a column is mapped to a nullable bool property to allow a difference between setting the property to false and invoking the default constraint. See https://go.microsoft.com/fwlink/?linkid=851278 for details. - Warning DesignEventId.NonNullableBoooleanColumnHasDefaultConstraintWarning string + + + Could not scaffold the foreign key '{foreignKeyName}'. The referenced table could not be found. This most likely occurred because the referenced table was excluded from scaffolding. + + + Could not scaffold the foreign key '{foreignKeyName}'. The following columns in the foreign key could not be scaffolded: {columnNames}. + + + Unable to scaffold the index '{indexName}'. The following columns could not be scaffolded: {columnNames}. + + + Sequence name cannot be null or empty. Entity Framework cannot model a sequence that does not have a name. \ No newline at end of file diff --git a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs index 0a4c6be9c62..b7beafd18ee 100644 --- a/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs +++ b/src/EFCore.Design/Scaffolding/Internal/RelationalScaffoldingModelFactory.cs @@ -7,7 +7,7 @@ using System.Linq; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Design; -using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Design.Internal; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -28,7 +28,7 @@ public class RelationalScaffoldingModelFactory : IScaffoldingModelFactory internal const string NavigationNameUniquifyingPattern = "{0}Navigation"; internal const string SelfReferencingPrincipalEndNavigationNamePattern = "Inverse{0}"; - protected virtual IDiagnosticsLogger Logger { get; } + protected virtual IOperationReporter Reporter { get; } protected virtual IRelationalTypeMapper TypeMapper { get; } protected virtual ICandidateNamingService CandidateNamingService { get; } @@ -43,7 +43,7 @@ public class RelationalScaffoldingModelFactory : IScaffoldingModelFactory private readonly IScaffoldingTypeMapper _scaffoldingTypeMapper; public RelationalScaffoldingModelFactory( - [NotNull] IDiagnosticsLogger logger, + [NotNull] IOperationReporter reporter, [NotNull] IRelationalTypeMapper typeMapper, [NotNull] IDatabaseModelFactory databaseModelFactory, [NotNull] ICandidateNamingService candidateNamingService, @@ -52,7 +52,7 @@ public RelationalScaffoldingModelFactory( [NotNull] ICSharpUtilities cSharpUtilities, [NotNull] IScaffoldingTypeMapper scaffoldingTypeMapper) { - Check.NotNull(logger, nameof(logger)); + Check.NotNull(reporter, nameof(reporter)); Check.NotNull(typeMapper, nameof(typeMapper)); Check.NotNull(databaseModelFactory, nameof(databaseModelFactory)); Check.NotNull(candidateNamingService, nameof(candidateNamingService)); @@ -61,7 +61,7 @@ public RelationalScaffoldingModelFactory( Check.NotNull(cSharpUtilities, nameof(cSharpUtilities)); Check.NotNull(scaffoldingTypeMapper, nameof(scaffoldingTypeMapper)); - Logger = logger; + Reporter = reporter; TypeMapper = typeMapper; CandidateNamingService = candidateNamingService; _databaseModelFactory = databaseModelFactory; @@ -171,7 +171,7 @@ protected virtual SequenceBuilder VisitSequence([NotNull] ModelBuilder modelBuil if (string.IsNullOrEmpty(sequence.Name)) { - Logger.SequenceNotNamedWarning(); + Reporter.WriteWarning(DesignStrings.SequencesRequireName); return null; } @@ -184,7 +184,7 @@ protected virtual SequenceBuilder VisitSequence([NotNull] ModelBuilder modelBuil if (sequenceType != null && !Sequence.SupportedTypes.Contains(sequenceType)) { - Logger.SequenceTypeNotSupportedWarning(sequence.Name, sequence.StoreType); + Reporter.WriteWarning(DesignStrings.BadSequenceType(sequence.Name, sequence.StoreType)); return null; } @@ -253,8 +253,8 @@ protected virtual EntityTypeBuilder VisitTable([NotNull] ModelBuilder modelBuild if (keyBuilder == null) { - var errorMessage = DesignStrings.LogUnableToGenerateEntityType.GenerateMessage(table.DisplayName()); - Logger.UnableToGenerateEntityTypeWarning(table.DisplayName()); + var errorMessage = DesignStrings.UnableToGenerateEntityType(table.DisplayName()); + Reporter.WriteWarning(errorMessage); var model = modelBuilder.Model; model.RemoveEntityType(entityTypeName); @@ -293,7 +293,8 @@ protected virtual PropertyBuilder VisitColumn([NotNull] EntityTypeBuilder builde if (typeScaffoldingInfo == null) { _unmappedColumns.Add(column); - Logger.ColumnTypeNotMappedWarning(column.DisplayName(), column.StoreType); + Reporter.WriteWarning( + DesignStrings.CannotFindTypeMappingForColumn(column.DisplayName(), column.StoreType)); return null; } @@ -301,8 +302,8 @@ protected virtual PropertyBuilder VisitColumn([NotNull] EntityTypeBuilder builde var forceNullable = typeof(bool) == clrType && column.DefaultValueSql != null; if (forceNullable) { - Logger.NonNullableBoooleanColumnHasDefaultConstraintWarning( - column.DisplayName()); + Reporter.WriteWarning( + DesignStrings.NonNullableBoooleanColumnHasDefaultConstraint(column.DisplayName())); } if (column.IsNullable || forceNullable) { @@ -374,7 +375,7 @@ protected virtual KeyBuilder VisitPrimaryKey([NotNull] EntityTypeBuilder builder var primaryKey = table.PrimaryKey; if (primaryKey == null) { - Logger.MissingPrimaryKeyWarning(table.DisplayName()); + Reporter.WriteWarning(DesignStrings.MissingPrimaryKey(table.DisplayName())); return null; } @@ -384,7 +385,10 @@ protected virtual KeyBuilder VisitPrimaryKey([NotNull] EntityTypeBuilder builder .ToList(); if (unmappedColumns.Any()) { - Logger.PrimaryKeyColumnsNotMappedWarning(table.DisplayName(), unmappedColumns); + Reporter.WriteWarning( + DesignStrings.PrimaryKeyErrorPropertyNotFound( + table.DisplayName(), + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumns))); return null; } @@ -434,7 +438,10 @@ protected virtual IndexBuilder VisitUniqueConstraint([NotNull] EntityTypeBuilder .ToList(); if (unmappedColumns.Any()) { - Logger.IndexColumnsNotMappedWarning(uniqueConstraint.Name, unmappedColumns); + Reporter.WriteWarning( + DesignStrings.UnableToScaffoldIndexMissingProperty( + uniqueConstraint.Name, + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumns))); return null; } @@ -477,7 +484,10 @@ protected virtual IndexBuilder VisitIndex([NotNull] EntityTypeBuilder builder, [ .ToList(); if (unmappedColumns.Any()) { - Logger.IndexColumnsNotMappedWarning(index.Name, unmappedColumns); + Reporter.WriteWarning( + DesignStrings.UnableToScaffoldIndexMissingProperty( + index.Name, + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumns))); return null; } @@ -528,7 +538,8 @@ protected virtual IMutableForeignKey VisitForeignKey([NotNull] ModelBuilder mode if (foreignKey.PrincipalTable == null) { - Logger.ForeignKeyReferencesMissingTableWarning(foreignKey.DisplayName()); + Reporter.WriteWarning( + DesignStrings.ForeignKeyScaffoldErrorPrincipalTableNotFound(foreignKey.DisplayName())); return null; } @@ -550,7 +561,10 @@ protected virtual IMutableForeignKey VisitForeignKey([NotNull] ModelBuilder mode .ToList(); if (unmappedDependentColumns.Any()) { - Logger.ForeignKeyColumnsNotMappedWarning(foreignKey.DisplayName(), unmappedDependentColumns); + Reporter.WriteWarning( + DesignStrings.ForeignKeyScaffoldErrorPropertyNotFound( + foreignKey.DisplayName(), + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedDependentColumns))); return null; } @@ -563,7 +577,10 @@ protected virtual IMutableForeignKey VisitForeignKey([NotNull] ModelBuilder mode var principalEntityType = modelBuilder.Model.FindEntityType(GetEntityTypeName(foreignKey.PrincipalTable)); if (principalEntityType == null) { - Logger.ForeignKeyReferencesNotMappedTableWarning(foreignKey.DisplayName(), foreignKey.PrincipalTable.DisplayName()); + Reporter.WriteWarning( + DesignStrings.ForeignKeyScaffoldErrorPrincipalTableScaffoldingError( + foreignKey.DisplayName(), + foreignKey.PrincipalTable.DisplayName())); return null; } @@ -573,7 +590,10 @@ protected virtual IMutableForeignKey VisitForeignKey([NotNull] ModelBuilder mode .ToList(); if (unmappedPrincipalColumns.Any()) { - Logger.ForeignKeyColumnsNotMappedWarning(foreignKey.DisplayName(), unmappedPrincipalColumns); + Reporter.WriteWarning( + DesignStrings.ForeignKeyScaffoldErrorPropertyNotFound( + foreignKey.DisplayName(), + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedPrincipalColumns))); return null; } @@ -597,10 +617,12 @@ protected virtual IMutableForeignKey VisitForeignKey([NotNull] ModelBuilder mode principalPropertiesMap.Where(tuple => tuple.property.IsNullable); if (nullablePrincipalProperties.Any()) { - Logger.ForeignKeyPrincipalEndContainsNullableColumnsWarning( - foreignKey.DisplayName(), - index.Relational().Name, - nullablePrincipalProperties.Select(tuple => tuple.column.DisplayName()).ToList()); + Reporter.WriteWarning( + DesignStrings.ForeignKeyPrincipalEndContainsNullableColumns( + foreignKey.DisplayName(), + index.Relational().Name, + nullablePrincipalProperties.Select(tuple => tuple.column.DisplayName()).ToList() + .Aggregate((a, b) => a + "," + b))); nullablePrincipalProperties .ToList() @@ -612,8 +634,11 @@ protected virtual IMutableForeignKey VisitForeignKey([NotNull] ModelBuilder mode { var principalColumns = foreignKey.PrincipalColumns.Select(c => c.Name).ToList(); - Logger.ForeignKeyReferencesMissingPrincipalKeyWarning( - foreignKey.DisplayName(), principalEntityType.DisplayName(), principalColumns); + Reporter.WriteWarning( + DesignStrings.ForeignKeyScaffoldErrorPrincipalKeyNotFound( + foreignKey.DisplayName(), + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, principalColumns), + principalEntityType.DisplayName())); return null; } diff --git a/src/EFCore.Relational.Design.Specification.Tests/ReverseEngineering/E2ETestBase.cs b/src/EFCore.Relational.Design.Specification.Tests/ReverseEngineering/E2ETestBase.cs index 0dd92cac401..c23d57271af 100644 --- a/src/EFCore.Relational.Design.Specification.Tests/ReverseEngineering/E2ETestBase.cs +++ b/src/EFCore.Relational.Design.Specification.Tests/ReverseEngineering/E2ETestBase.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore.Scaffolding.Internal; using Microsoft.EntityFrameworkCore.TestUtilities; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Xunit; using Xunit.Abstractions; using Xunit.Sdk; @@ -18,7 +17,7 @@ namespace Microsoft.EntityFrameworkCore.ReverseEngineering public abstract class E2ETestBase { private readonly ITestOutputHelper _output; - protected InMemoryOperationReporter _reporter; + protected TestOperationReporter _reporter; protected InMemoryFileService InMemoryFiles; protected readonly IModelScaffolder Generator; protected readonly IScaffoldingModelFactory ScaffoldingModelFactory; @@ -27,7 +26,10 @@ protected E2ETestBase(ITestOutputHelper output) { _output = output; + _reporter = new TestOperationReporter(); + var serviceBuilder = new ServiceCollection() + .AddSingleton(_reporter) .AddScaffolding() .AddLogging(); @@ -37,10 +39,6 @@ protected E2ETestBase(ITestOutputHelper output) .AddSingleton(typeof(IFileService), sp => InMemoryFiles = new InMemoryFileService()) .BuildServiceProvider(); - _reporter = new InMemoryOperationReporter(_output); - var factory = serviceProvider.GetService(); - factory.AddProvider(new LoggerProvider(categoryName => new OperationLogger(categoryName, _reporter))); - Generator = serviceProvider.GetRequiredService(); ScaffoldingModelFactory = serviceProvider.GetRequiredService(); } @@ -77,38 +75,6 @@ protected virtual void AssertEqualFileContents(FileSet expected, FileSet actual) } } - protected virtual void AssertLog(LoggerMessages expected) - { - AssertLoggerMessages(expected.Error, _reporter.Messages.Error, "ERROR"); - AssertLoggerMessages(expected.Warn, _reporter.Messages.Warn, "WARNING"); - AssertLoggerMessages(expected.Info, _reporter.Messages.Info, "INFO"); - AssertLoggerMessages(expected.Debug, _reporter.Messages.Info, "DEBUG"); - } - - protected virtual void AssertLoggerMessages( - List expected, List actual, string category) - { - try - { - foreach (var message in expected) - { - Assert.Contains(message, actual); - } - - Assert.Equal(expected.Count, actual.Count); - } - catch (Exception) - { - var sep = new string('=', 60); - _output.WriteLine($"Contents of {category} logger messages:"); - _output.WriteLine(sep); - _output.WriteLine(string.Join(Environment.NewLine, actual)); - _output.WriteLine(sep); - - throw; - } - } - protected virtual void AssertCompile(FileSet fileSet) { var fileContents = fileSet.Files.Select(fileSet.Contents).ToList(); diff --git a/src/EFCore.Relational.Design.Specification.Tests/ReverseEngineering/InMemoryOperationReporter.cs b/src/EFCore.Relational.Design.Specification.Tests/ReverseEngineering/InMemoryOperationReporter.cs deleted file mode 100644 index ad7696f2df5..00000000000 --- a/src/EFCore.Relational.Design.Specification.Tests/ReverseEngineering/InMemoryOperationReporter.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Design.Internal; -using Xunit.Abstractions; - -namespace Microsoft.EntityFrameworkCore.ReverseEngineering -{ - public class InMemoryOperationReporter : IOperationReporter - { - public LoggerMessages Messages = new LoggerMessages(); - private readonly ITestOutputHelper _output; - private static readonly bool _logToOutput = false; - - public InMemoryOperationReporter(ITestOutputHelper output) => _output = output; - - public void WriteError(string message) - { - if (_logToOutput) - { - _output?.WriteLine("[ERROR]: " + message); - } - - Messages.Error.Add(message); - } - - public void WriteWarning(string message) - { - if (_logToOutput) - { - _output?.WriteLine("[WARN]: " + message); - } - - Messages.Warn.Add(message); - } - - public void WriteInformation(string message) - { - if (_logToOutput) - { - _output?.WriteLine("[INFO]: " + message); - } - - Messages.Info.Add(message); - } - - public void WriteVerbose(string message) - { - if (_logToOutput) - { - _output?.WriteLine("[DEBUG]: " + message); - } - - Messages.Debug.Add(message); - } - } - - public class LoggerMessages - { - public List Error = new List(); - public List Warn = new List(); - public List Info = new List(); - public List Debug = new List(); - } -} diff --git a/test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs b/src/EFCore.Relational.Design.Specification.Tests/TestUtilities/TestOperationReporter.cs similarity index 100% rename from test/EFCore.Design.Tests/TestUtilities/TestOperationReporter.cs rename to src/EFCore.Relational.Design.Specification.Tests/TestUtilities/TestOperationReporter.cs diff --git a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs index acf74a59192..00d77bf8a0d 100644 --- a/src/EFCore.Relational/Diagnostics/RelationalEventId.cs +++ b/src/EFCore.Relational/Diagnostics/RelationalEventId.cs @@ -62,33 +62,7 @@ private enum Id // Model validation events ModelValidationKeyDefaultValueWarning = CoreEventId.RelationalBaseId + 600, - BoolWithDefaultWarning, - - // Scaffolding warning events - MissingSchemaWarning = CoreEventId.CoreDesignBaseId + 700, - MissingTableWarning, - SequenceNotNamedWarning, - IndexColumnsNotMappedWarning, - ForeignKeyReferencesMissingTableWarning, - ForeignKeyReferencesMissingPrincipalTableWarning, - ForeignKeyColumnsNotMappedWarning, - ForeignKeyNotNamedWarning, - ForeignKeyColumnMissingWarning, - ForeignKeyColumnNotNamedWarning, - ForeignKeyPrincipalColumnMissingWarning, - ColumnNotNamedWarning, - IndexNotNamedWarning, - IndexTableMissingWarning, - IndexColumnNotNamedWarning, - - // Scaffolding events - TableFound = CoreEventId.CoreDesignBaseId + 800, - TableSkipped, - ColumnSkipped, - IndexFound, - IndexColumnFound, - IndexColumnSkipped, - SequenceFound + BoolWithDefaultWarning } private static readonly string _connectionPrefix = DbLoggerCategory.Database.Connection.Name + "."; @@ -460,140 +434,5 @@ private enum Id /// /// public static readonly EventId BoolWithDefaultWarning = MakeValidationId(Id.BoolWithDefaultWarning); - - private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + "."; - private static EventId MakeScaffoldingId(Id id) => new EventId((int)id, _scaffoldingPrefix + id); - - /// - /// The database is missing a schema. - /// This event is in the category. - /// - public static readonly EventId MissingSchemaWarning = MakeScaffoldingId(Id.MissingSchemaWarning); - - /// - /// The database is missing a table. - /// This event is in the category. - /// - public static readonly EventId MissingTableWarning = MakeScaffoldingId(Id.MissingTableWarning); - - /// - /// The database has an unnamed sequence. - /// This event is in the category. - /// - public static readonly EventId SequenceNotNamedWarning = MakeScaffoldingId(Id.SequenceNotNamedWarning); - - /// - /// Columns in an index were not mapped. - /// This event is in the category. - /// - public static readonly EventId IndexColumnsNotMappedWarning = MakeScaffoldingId(Id.IndexColumnsNotMappedWarning); - - /// - /// A foreign key references a missing table. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyReferencesMissingTableWarning = MakeScaffoldingId(Id.ForeignKeyReferencesMissingTableWarning); - - /// - /// A foreign key references a missing table at the principal end. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyReferencesMissingPrincipalTableWarning = MakeScaffoldingId(Id.ForeignKeyReferencesMissingPrincipalTableWarning); - - /// - /// Columns in a foreign key were not mapped. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyColumnsNotMappedWarning = MakeScaffoldingId(Id.ForeignKeyColumnsNotMappedWarning); - - /// - /// A foreign key is not named. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyNotNamedWarning = MakeScaffoldingId(Id.ForeignKeyNotNamedWarning); - - /// - /// A foreign key column was not found. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyColumnMissingWarning = MakeScaffoldingId(Id.ForeignKeyColumnMissingWarning); - - /// - /// A column referenced by a foreign key constraint was not found. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyPrincipalColumnMissingWarning = MakeScaffoldingId(Id.ForeignKeyPrincipalColumnMissingWarning); - - /// - /// A foreign key column was not named. - /// This event is in the category. - /// - public static readonly EventId ForeignKeyColumnNotNamedWarning = MakeScaffoldingId(Id.ForeignKeyColumnNotNamedWarning); - - /// - /// A column is not named. - /// This event is in the category. - /// - public static readonly EventId ColumnNotNamedWarning = MakeScaffoldingId(Id.ColumnNotNamedWarning); - - /// - /// An index is not named. - /// This event is in the category. - /// - public static readonly EventId IndexNotNamedWarning = MakeScaffoldingId(Id.IndexNotNamedWarning); - - /// - /// The table referened by an index was not found. - /// This event is in the category. - /// - public static readonly EventId IndexTableMissingWarning = MakeScaffoldingId(Id.IndexTableMissingWarning); - - /// - /// An index column was not named. - /// This event is in the category. - /// - public static readonly EventId IndexColumnNotNamedWarning = MakeScaffoldingId(Id.IndexColumnNotNamedWarning); - - /// - /// A table was found. - /// This event is in the category. - /// - public static readonly EventId TableFound = MakeScaffoldingId(Id.TableFound); - - /// - /// A table was skipped. - /// This event is in the category. - /// - public static readonly EventId TableSkipped = MakeScaffoldingId(Id.TableSkipped); - - /// - /// A column was skipped. - /// This event is in the category. - /// - public static readonly EventId ColumnSkipped = MakeScaffoldingId(Id.ColumnSkipped); - - /// - /// An index was found. - /// This event is in the category. - /// - public static readonly EventId IndexFound = MakeScaffoldingId(Id.IndexFound); - - /// - /// An index was skipped. - /// This event is in the category. - /// - public static readonly EventId IndexColumnFound = MakeScaffoldingId(Id.IndexColumnFound); - - /// - /// A column of an index was skipped. - /// This event is in the category. - /// - public static readonly EventId IndexColumnSkipped = MakeScaffoldingId(Id.IndexColumnSkipped); - - /// - /// A sequence was found. - /// This event is in the category. - /// - public static readonly EventId SequenceFound = MakeScaffoldingId(Id.SequenceFound); } } diff --git a/src/EFCore.Relational/Internal/RelationalLoggerExtensions.cs b/src/EFCore.Relational/Internal/RelationalLoggerExtensions.cs index 3f8699ea75f..8c233dd1de5 100644 --- a/src/EFCore.Relational/Internal/RelationalLoggerExtensions.cs +++ b/src/EFCore.Relational/Internal/RelationalLoggerExtensions.cs @@ -2,10 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Data; using System.Data.Common; -using System.Diagnostics; using System.Globalization; using System.Linq.Expressions; using JetBrains.Annotations; @@ -16,7 +14,6 @@ using Microsoft.EntityFrameworkCore.Migrations.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Storage.Internal; -using Microsoft.Extensions.Logging; using Remotion.Linq; namespace Microsoft.EntityFrameworkCore.Internal @@ -1119,278 +1116,5 @@ private static string BoolWithDefaultWarning(EventDefinitionBase definition, Eve var p = (PropertyEventData)payload; return d.GenerateMessage(p.Property.Name, p.Property.DeclaringEntityType.DisplayName()); } - - /// - /// 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. - /// - public static void MissingSchemaWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string schemaName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogMissingSchema.Log(diagnostics, schemaName); - - /// - /// 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. - /// - public static void MissingTableWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogMissingTable.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void SequenceNotNamedWarning( - [NotNull] this IDiagnosticsLogger diagnostics) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogSequencesRequireName.Log(diagnostics); - - /// - /// 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. - /// - public static void IndexColumnsNotMappedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string indexName, - [NotNull] IList unmappedColumnNames) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogUnableToScaffoldIndexMissingProperty.Log( - diagnostics, - indexName, - string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumnNames)); - - /// - /// 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. - /// - public static void ForeignKeyReferencesMissingTableWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogForeignKeyScaffoldErrorPrincipalTableNotFound.Log(diagnostics, foreignKeyName); - - /// - /// 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. - /// - public static void ForeignKeyColumnsNotMappedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName, - [NotNull] IList unmappedColumnNames) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogForeignKeyScaffoldErrorPropertyNotFound.Log( - diagnostics, - foreignKeyName, - string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumnNames)); - - /// - /// 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. - /// - public static void SequenceFound( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string sequenceName, - [CanBeNull] string sequenceTypeName, - bool? cyclic, - int? increment, - long? start, - long? min, - long? max) - { - // No DiagnosticsSource events because these are purely design-time messages - var definition = RelationalStrings.LogFoundSequence; - - Debug.Assert(LogLevel.Debug == definition.Level); - - if (diagnostics.GetLogBehavior(definition.EventId, definition.Level) != WarningBehavior.Ignore) - { - definition.Log( - diagnostics, - l => l.LogDebug( - definition.EventId, - null, - definition.MessageFormat, - sequenceName, - sequenceTypeName, - cyclic, - increment, - start, - min, - max)); - } - } - - /// - /// 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. - /// - public static void TableFound( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogFoundTable.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void TableSkipped( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogTableNotInSelectionSet.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void ColumnSkipped( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName, - [CanBeNull] string columnName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogColumnNotInSelectionSet.Log(diagnostics, columnName, tableName); - - /// - /// 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. - /// - public static void IndexColumnFound( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName, - [CanBeNull] string indexName, - bool? unique, - [CanBeNull] string columnName, - int? ordinal) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogFoundIndexColumn.Log(diagnostics, indexName, tableName, columnName, ordinal); - - /// - /// 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. - /// - public static void ColumnNotNamedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogColumnNameEmptyOnTable.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void IndexColumnSkipped( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName, - [CanBeNull] string indexName, - [CanBeNull] string columnName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogIndexColumnNotInSelectionSet.Log(diagnostics, columnName, indexName, tableName); - - /// - /// 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. - /// - public static void IndexNotNamedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogIndexNameEmpty.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void IndexTableMissingWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string indexName, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogUnableToFindTableForIndex.Log(diagnostics, indexName, tableName); - - /// - /// 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. - /// - public static void IndexColumnNotNamedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string indexName, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogColumnNameEmptyOnIndex.Log(diagnostics, indexName, tableName); - - /// - /// 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. - /// - public static void ForeignKeyNotNamedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogForeignKeyNameEmpty.Log(diagnostics, tableName); - - /// - /// 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. - /// - public static void ForeignKeyColumnMissingWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string columnName, - [CanBeNull] string foreignKeyName, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogForeignKeyColumnNotInSelectionSet.Log(diagnostics, columnName, foreignKeyName, tableName); - - /// - /// 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. - /// - public static void ForeignKeyReferencesMissingPrincipalTableWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName, - [CanBeNull] string tableName, - [CanBeNull] string principalTableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogPrincipalTableNotInSelectionSet.Log(diagnostics, foreignKeyName, tableName, principalTableName); - - /// - /// 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. - /// - public static void ForeignKeyColumnNotNamedWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName, - [CanBeNull] string tableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogColumnNameEmptyOnForeignKey.Log(diagnostics, tableName, foreignKeyName); - - /// - /// 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. - /// - public static void IndexFound( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string indexName, - [CanBeNull] string tableName, - bool? unique) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogFoundIndex.Log(diagnostics, indexName, tableName, unique); - - /// - /// 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. - /// - public static void ForeignKeyPrincipalColumnMissingWarning( - [NotNull] this IDiagnosticsLogger diagnostics, - [CanBeNull] string foreignKeyName, - [CanBeNull] string tableName, - [CanBeNull] string principalColumnName, - [CanBeNull] string principalTableName) - // No DiagnosticsSource events because these are purely design-time messages - => RelationalStrings.LogPrincipalColumnNotFound.Log(diagnostics, foreignKeyName, tableName, principalColumnName, principalTableName); } } diff --git a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs index b18670eb3ae..8c10fd2bc63 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs +++ b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs @@ -770,267 +770,6 @@ public static string UnsupportedPropertyType([CanBeNull] object entity, [CanBeNu GetString("UnsupportedPropertyType", nameof(entity), nameof(property), nameof(clrType)), entity, property, clrType); - /// - /// Found sequence name: {name}, data type: {dataType}, cyclic: {isCyclic}, increment: {increment}, start: {start}, minimum: {min}, maximum: {max}. - /// - public static readonly FallbackEventDefinition LogFoundSequence - = new FallbackEventDefinition( - RelationalEventId.SequenceFound, - LogLevel.Debug, - _resourceManager.GetString("LogFoundSequence")); - - /// - /// Sequence name cannot be null or empty. Entity Framework cannot model a sequence that does not have a name. - /// - public static readonly EventDefinition LogSequencesRequireName - = new EventDefinition( - RelationalEventId.SequenceNotNamedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.SequenceNotNamedWarning, - _resourceManager.GetString("LogSequencesRequireName"))); - - /// - /// Found table with name: {name}. - /// - public static readonly EventDefinition LogFoundTable - = new EventDefinition( - RelationalEventId.TableFound, - LogLevel.Debug, - LoggerMessage.Define( - LogLevel.Debug, - RelationalEventId.TableFound, - _resourceManager.GetString("LogFoundTable"))); - - /// - /// Table {tableName} is not included in the selection set. Skipping. - /// - public static readonly EventDefinition LogTableNotInSelectionSet - = new EventDefinition( - RelationalEventId.TableSkipped, - LogLevel.Debug, - LoggerMessage.Define( - LogLevel.Debug, - RelationalEventId.TableSkipped, - _resourceManager.GetString("LogTableNotInSelectionSet"))); - - /// - /// Column {columnName} belongs to table {tableName} which is not included in the selection set. Skipping. - /// - public static readonly EventDefinition LogColumnNotInSelectionSet - = new EventDefinition( - RelationalEventId.ColumnSkipped, - LogLevel.Debug, - LoggerMessage.Define( - LogLevel.Debug, - RelationalEventId.ColumnSkipped, - _resourceManager.GetString("LogColumnNotInSelectionSet"))); - - /// - /// Found a column on table {tableName} with an empty or null name. Skipping column. - /// - public static readonly EventDefinition LogColumnNameEmptyOnTable - = new EventDefinition( - RelationalEventId.ColumnNotNamedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ColumnNotNamedWarning, - _resourceManager.GetString("LogColumnNameEmptyOnTable"))); - - /// - /// Unable to find a schema in the database matching the selected schema {schema}. - /// - public static readonly EventDefinition LogMissingSchema - = new EventDefinition( - RelationalEventId.MissingSchemaWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.MissingSchemaWarning, - _resourceManager.GetString("LogMissingSchema"))); - - /// - /// Unable to find a table in the database matching the selected table {table}. - /// - public static readonly EventDefinition LogMissingTable - = new EventDefinition( - RelationalEventId.MissingTableWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.MissingTableWarning, - _resourceManager.GetString("LogMissingTable"))); - - /// - /// Found index column on index {indexName} on table {tableName}, column name: {columnName}, ordinal: {ordinal}. - /// - public static readonly EventDefinition LogFoundIndexColumn - = new EventDefinition( - RelationalEventId.IndexColumnFound, - LogLevel.Debug, - LoggerMessage.Define( - LogLevel.Debug, - RelationalEventId.IndexColumnFound, - _resourceManager.GetString("LogFoundIndexColumn"))); - - /// - /// Index column {columnName} belongs to index {indexName} on table {tableName} which is not included in the selection set. Skipping. - /// - public static readonly EventDefinition LogIndexColumnNotInSelectionSet - = new EventDefinition( - RelationalEventId.IndexColumnSkipped, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.IndexColumnSkipped, - _resourceManager.GetString("LogIndexColumnNotInSelectionSet"))); - - /// - /// Found an index on table {tableName} with an empty or null name. Skipping index. - /// - public static readonly EventDefinition LogIndexNameEmpty - = new EventDefinition( - RelationalEventId.IndexNotNamedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.IndexNotNamedWarning, - _resourceManager.GetString("LogIndexNameEmpty"))); - - /// - /// For index {indexName}. Unable to find parent table {tableName}. Skipping index. - /// - public static readonly EventDefinition LogUnableToFindTableForIndex - = new EventDefinition( - RelationalEventId.IndexTableMissingWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.IndexTableMissingWarning, - _resourceManager.GetString("LogUnableToFindTableForIndex"))); - - /// - /// Found a column on index {indexName} on table {tableName} with an empty or null name. Not including column in index. - /// - public static readonly EventDefinition LogColumnNameEmptyOnIndex - = new EventDefinition( - RelationalEventId.IndexColumnNotNamedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.IndexColumnNotNamedWarning, - _resourceManager.GetString("LogColumnNameEmptyOnIndex"))); - - /// - /// Unable to scaffold the index '{indexName}'. The following columns could not be scaffolded: {columnNames}. - /// - public static readonly EventDefinition LogUnableToScaffoldIndexMissingProperty - = new EventDefinition( - RelationalEventId.IndexColumnsNotMappedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.IndexColumnsNotMappedWarning, - _resourceManager.GetString("LogUnableToScaffoldIndexMissingProperty"))); - - /// - /// Found a foreign key on table {tableName} with an empty or null name. Skipping foreign key. - /// - public static readonly EventDefinition LogForeignKeyNameEmpty - = new EventDefinition( - RelationalEventId.ForeignKeyNotNamedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ForeignKeyNotNamedWarning, - _resourceManager.GetString("LogForeignKeyNameEmpty"))); - - /// - /// Foreign key column {columnName} belongs to foreign key {fkName} on table {tableName} which is not included in the selection set. Skipping. - /// - public static readonly EventDefinition LogForeignKeyColumnNotInSelectionSet - = new EventDefinition( - RelationalEventId.ForeignKeyColumnMissingWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ForeignKeyColumnMissingWarning, - _resourceManager.GetString("LogForeignKeyColumnNotInSelectionSet"))); - - /// - /// For foreign key {fkName} on table {tableName}, unable to model the end of the foreign key on principal table {principaltableName}. This is usually because the principal table was not included in the selection set. - /// - public static readonly EventDefinition LogPrincipalTableNotInSelectionSet - = new EventDefinition( - RelationalEventId.ForeignKeyReferencesMissingPrincipalTableWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ForeignKeyReferencesMissingPrincipalTableWarning, - _resourceManager.GetString("LogPrincipalTableNotInSelectionSet"))); - - /// - /// Found a column on foreign key {tableName}.{fkName} with an empty or null name. Not including column in foreign key - /// - public static readonly EventDefinition LogColumnNameEmptyOnForeignKey - = new EventDefinition( - RelationalEventId.ForeignKeyColumnNotNamedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ForeignKeyColumnNotNamedWarning, - _resourceManager.GetString("LogColumnNameEmptyOnForeignKey"))); - - /// - /// Could not scaffold the foreign key '{foreignKeyName}'. The following columns in the foreign key could not be scaffolded: {columnNames}. - /// - public static readonly EventDefinition LogForeignKeyScaffoldErrorPropertyNotFound - = new EventDefinition( - RelationalEventId.ForeignKeyColumnsNotMappedWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ForeignKeyColumnsNotMappedWarning, - _resourceManager.GetString("LogForeignKeyScaffoldErrorPropertyNotFound"))); - - /// - /// Found index with name: {indexName}, table: {tableName}, is unique: {isUnique}. - /// - public static readonly EventDefinition LogFoundIndex - = new EventDefinition( - RelationalEventId.IndexFound, - LogLevel.Debug, - LoggerMessage.Define( - LogLevel.Debug, - RelationalEventId.IndexFound, - _resourceManager.GetString("LogFoundIndex"))); - - /// - /// Could not scaffold the foreign key '{foreignKeyName}'. The referenced table could not be found. This most likely occurred because the referenced table was excluded from scaffolding. - /// - public static readonly EventDefinition LogForeignKeyScaffoldErrorPrincipalTableNotFound - = new EventDefinition( - RelationalEventId.ForeignKeyReferencesMissingTableWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ForeignKeyReferencesMissingTableWarning, - _resourceManager.GetString("LogForeignKeyScaffoldErrorPrincipalTableNotFound"))); - - /// - /// For foreign key with identity {id} on table {tableName}, unable to find the column called {principalColumnName} on the foreign key's principal table, {principaltableName}. Skipping foreign key. - /// - public static readonly EventDefinition LogPrincipalColumnNotFound - = new EventDefinition( - RelationalEventId.ForeignKeyPrincipalColumnMissingWarning, - LogLevel.Warning, - LoggerMessage.Define( - LogLevel.Warning, - RelationalEventId.ForeignKeyPrincipalColumnMissingWarning, - _resourceManager.GetString("LogPrincipalColumnNotFound"))); - /// /// An error occurred using the connection to database '{database}' on server '{server}'. /// diff --git a/src/EFCore.Relational/Properties/RelationalStrings.resx b/src/EFCore.Relational/Properties/RelationalStrings.resx index 9d8b50605ed..2f8cea2f9a3 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.resx +++ b/src/EFCore.Relational/Properties/RelationalStrings.resx @@ -396,94 +396,6 @@ No mapping to a relational type can be found for property '{entity}.{property}' with the CLR type '{clrType}'. - - Found sequence name: {name}, data type: {dataType}, cyclic: {isCyclic}, increment: {increment}, start: {start}, minimum: {min}, maximum: {max}. - Debug RelationalEventId.SequenceFound string string bool? int? long? long? long? - - - Sequence name cannot be null or empty. Entity Framework cannot model a sequence that does not have a name. - Warning RelationalEventId.SequenceNotNamedWarning - - - Found table with name: {name}. - Debug RelationalEventId.TableFound string - - - Table {tableName} is not included in the selection set. Skipping. - Debug RelationalEventId.TableSkipped string - - - Column {columnName} belongs to table {tableName} which is not included in the selection set. Skipping. - Debug RelationalEventId.ColumnSkipped string string - - - Found a column on table {tableName} with an empty or null name. Skipping column. - Warning RelationalEventId.ColumnNotNamedWarning string - - - Unable to find a schema in the database matching the selected schema {schema}. - Warning RelationalEventId.MissingSchemaWarning string - - - Unable to find a table in the database matching the selected table {table}. - Warning RelationalEventId.MissingTableWarning string - - - Found index column on index {indexName} on table {tableName}, column name: {columnName}, ordinal: {ordinal}. - Debug RelationalEventId.IndexColumnFound string string string int? - - - Index column {columnName} belongs to index {indexName} on table {tableName} which is not included in the selection set. Skipping. - Warning RelationalEventId.IndexColumnSkipped string string string - - - Found an index on table {tableName} with an empty or null name. Skipping index. - Warning RelationalEventId.IndexNotNamedWarning string - - - For index {indexName}. Unable to find parent table {tableName}. Skipping index. - Warning RelationalEventId.IndexTableMissingWarning string string - - - Found a column on index {indexName} on table {tableName} with an empty or null name. Not including column in index. - Warning RelationalEventId.IndexColumnNotNamedWarning string string - - - Unable to scaffold the index '{indexName}'. The following columns could not be scaffolded: {columnNames}. - Warning RelationalEventId.IndexColumnsNotMappedWarning string string - - - Found a foreign key on table {tableName} with an empty or null name. Skipping foreign key. - Warning RelationalEventId.ForeignKeyNotNamedWarning string - - - Foreign key column {columnName} belongs to foreign key {fkName} on table {tableName} which is not included in the selection set. Skipping. - Warning RelationalEventId.ForeignKeyColumnMissingWarning string string string - - - For foreign key {fkName} on table {tableName}, unable to model the end of the foreign key on principal table {principaltableName}. This is usually because the principal table was not included in the selection set. - Warning RelationalEventId.ForeignKeyReferencesMissingPrincipalTableWarning string string string - - - Found a column on foreign key {tableName}.{fkName} with an empty or null name. Not including column in foreign key - Warning RelationalEventId.ForeignKeyColumnNotNamedWarning string string - - - Could not scaffold the foreign key '{foreignKeyName}'. The following columns in the foreign key could not be scaffolded: {columnNames}. - Warning RelationalEventId.ForeignKeyColumnsNotMappedWarning string string - - - Found index with name: {indexName}, table: {tableName}, is unique: {isUnique}. - Debug RelationalEventId.IndexFound string string bool? - - - Could not scaffold the foreign key '{foreignKeyName}'. The referenced table could not be found. This most likely occurred because the referenced table was excluded from scaffolding. - Warning RelationalEventId.ForeignKeyReferencesMissingTableWarning string - - - For foreign key with identity {id} on table {tableName}, unable to find the column called {principalColumnName} on the foreign key's principal table, {principaltableName}. Skipping foreign key. - Warning RelationalEventId.ForeignKeyPrincipalColumnMissingWarning string string string string - An error occurred using the connection to database '{database}' on server '{server}'. Debug RelationalEventId.ConnectionError string string diff --git a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs index 8bebfaab9a8..4e4ce4de2fc 100644 --- a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs +++ b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs @@ -27,9 +27,29 @@ private enum Id DecimalTypeDefaultWarning = CoreEventId.ProviderBaseId, ByteIdentityColumnWarning, - ColumnFound = CoreEventId.ProviderBaseId + 100, - ForeignKeyColumnFound, + // Scaffolding events + ColumnFound = CoreEventId.ProviderDesignBaseId, + ColumnNotNamedWarning, + ColumnSkipped, DefaultSchemaFound, + ForeignKeyColumnFound, + ForeignKeyColumnMissingWarning, + ForeignKeyColumnNotNamedWarning, + ForeignKeyColumnsNotMappedWarning, + ForeignKeyNotNamedWarning, + ForeignKeyReferencesMissingPrincipalTableWarning, + IndexColumnFound, + IndexColumnNotNamedWarning, + IndexColumnSkipped, + IndexColumnsNotMappedWarning, + IndexNotNamedWarning, + IndexTableMissingWarning, + MissingSchemaWarning, + MissingTableWarning, + SequenceFound, + SequenceNotNamedWarning, + TableFound, + TableSkipped, TypeAliasFound } @@ -88,5 +108,119 @@ private enum Id /// This event is in the category. /// public static readonly EventId TypeAliasFound = MakeScaffoldingId(Id.TypeAliasFound); + + /// + /// The database is missing a schema. + /// This event is in the category. + /// + public static readonly EventId MissingSchemaWarning = MakeScaffoldingId(Id.MissingSchemaWarning); + + /// + /// The database is missing a table. + /// This event is in the category. + /// + public static readonly EventId MissingTableWarning = MakeScaffoldingId(Id.MissingTableWarning); + + /// + /// The database has an unnamed sequence. + /// This event is in the category. + /// + public static readonly EventId SequenceNotNamedWarning = MakeScaffoldingId(Id.SequenceNotNamedWarning); + + /// + /// Columns in an index were not mapped. + /// This event is in the category. + /// + public static readonly EventId IndexColumnsNotMappedWarning = MakeScaffoldingId(Id.IndexColumnsNotMappedWarning); + + /// + /// A foreign key references a missing table at the principal end. + /// This event is in the category. + /// + public static readonly EventId ForeignKeyReferencesMissingPrincipalTableWarning = MakeScaffoldingId(Id.ForeignKeyReferencesMissingPrincipalTableWarning); + + /// + /// Columns in a foreign key were not mapped. + /// This event is in the category. + /// + public static readonly EventId ForeignKeyColumnsNotMappedWarning = MakeScaffoldingId(Id.ForeignKeyColumnsNotMappedWarning); + + /// + /// A foreign key is not named. + /// This event is in the category. + /// + public static readonly EventId ForeignKeyNotNamedWarning = MakeScaffoldingId(Id.ForeignKeyNotNamedWarning); + + /// + /// A foreign key column was not found. + /// This event is in the category. + /// + public static readonly EventId ForeignKeyColumnMissingWarning = MakeScaffoldingId(Id.ForeignKeyColumnMissingWarning); + + /// + /// A foreign key column was not named. + /// This event is in the category. + /// + public static readonly EventId ForeignKeyColumnNotNamedWarning = MakeScaffoldingId(Id.ForeignKeyColumnNotNamedWarning); + + /// + /// A column is not named. + /// This event is in the category. + /// + public static readonly EventId ColumnNotNamedWarning = MakeScaffoldingId(Id.ColumnNotNamedWarning); + + /// + /// An index is not named. + /// This event is in the category. + /// + public static readonly EventId IndexNotNamedWarning = MakeScaffoldingId(Id.IndexNotNamedWarning); + + /// + /// The table referened by an index was not found. + /// This event is in the category. + /// + public static readonly EventId IndexTableMissingWarning = MakeScaffoldingId(Id.IndexTableMissingWarning); + + /// + /// An index column was not named. + /// This event is in the category. + /// + public static readonly EventId IndexColumnNotNamedWarning = MakeScaffoldingId(Id.IndexColumnNotNamedWarning); + + /// + /// A table was found. + /// This event is in the category. + /// + public static readonly EventId TableFound = MakeScaffoldingId(Id.TableFound); + + /// + /// A table was skipped. + /// This event is in the category. + /// + public static readonly EventId TableSkipped = MakeScaffoldingId(Id.TableSkipped); + + /// + /// A column was skipped. + /// This event is in the category. + /// + public static readonly EventId ColumnSkipped = MakeScaffoldingId(Id.ColumnSkipped); + + /// + /// An index was skipped. + /// This event is in the category. + /// + public static readonly EventId IndexColumnFound = MakeScaffoldingId(Id.IndexColumnFound); + + /// + /// A column of an index was skipped. + /// This event is in the category. + /// + public static readonly EventId IndexColumnSkipped = MakeScaffoldingId(Id.IndexColumnSkipped); + + /// + /// A sequence was found. + /// This event is in the category. + /// + public static readonly EventId SequenceFound = MakeScaffoldingId(Id.SequenceFound); } } diff --git a/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs b/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs index 2360d9c0c5a..8b2e47bcf51 100644 --- a/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs +++ b/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs @@ -1,7 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; @@ -198,5 +200,243 @@ public static void TypeAliasFound( [CanBeNull] string systemTypeName) // No DiagnosticsSource events because these are purely design-time messages => SqlServerStrings.LogFoundTypeAlias.Log(diagnostics, typeAliasName, systemTypeName); + + /// + /// 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. + /// + public static void IndexColumnNotNamedWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string indexName, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogColumnNameEmptyOnIndex.Log(diagnostics, indexName, tableName); + + /// + /// 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. + /// + public static void ColumnSkipped( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName, + [CanBeNull] string columnName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogColumnNotInSelectionSet.Log(diagnostics, columnName, tableName); + + /// + /// 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. + /// + public static void ForeignKeyColumnMissingWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string columnName, + [CanBeNull] string foreignKeyName, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogForeignKeyColumnNotInSelectionSet.Log(diagnostics, columnName, foreignKeyName, tableName); + + /// + /// 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. + /// + public static void ForeignKeyNotNamedWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogForeignKeyNameEmpty.Log(diagnostics, tableName); + + /// + /// 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. + /// + public static void ForeignKeyColumnsNotMappedWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string foreignKeyName, + [NotNull] IList unmappedColumnNames) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogForeignKeyScaffoldErrorPropertyNotFound.Log( + diagnostics, + foreignKeyName, + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumnNames)); + + /// + /// 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. + /// + public static void ForeignKeyReferencesMissingPrincipalTableWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string foreignKeyName, + [CanBeNull] string tableName, + [CanBeNull] string principalTableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogPrincipalTableNotInSelectionSet.Log(diagnostics, foreignKeyName, tableName, principalTableName); + + /// + /// 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. + /// + public static void IndexColumnFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName, + [CanBeNull] string indexName, + bool? unique, + [CanBeNull] string columnName, + int? ordinal) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogFoundIndexColumn.Log(diagnostics, indexName, tableName, columnName, ordinal); + + /// + /// 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. + /// + public static void IndexColumnSkipped( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName, + [CanBeNull] string indexName, + [CanBeNull] string columnName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogIndexColumnNotInSelectionSet.Log(diagnostics, columnName, indexName, tableName); + + /// + /// 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. + /// + public static void IndexColumnsNotMappedWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string indexName, + [NotNull] IList unmappedColumnNames) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogUnableToScaffoldIndexMissingProperty.Log( + diagnostics, + indexName, + string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, unmappedColumnNames)); + + /// + /// 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. + /// + public static void IndexNotNamedWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogIndexNameEmpty.Log(diagnostics, tableName); + + /// + /// 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. + /// + public static void IndexTableMissingWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string indexName, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogUnableToFindTableForIndex.Log(diagnostics, indexName, tableName); + + /// + /// 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. + /// + public static void MissingSchemaWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string schemaName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogMissingSchema.Log(diagnostics, schemaName); + + /// + /// 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. + /// + public static void MissingTableWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogMissingTable.Log(diagnostics, tableName); + + /// + /// 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. + /// + public static void SequenceFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string sequenceName, + [CanBeNull] string sequenceTypeName, + bool? cyclic, + int? increment, + long? start, + long? min, + long? max) + { + // No DiagnosticsSource events because these are purely design-time messages + var definition = SqlServerStrings.LogFoundSequence; + + Debug.Assert(LogLevel.Debug == definition.Level); + + if (diagnostics.GetLogBehavior(definition.EventId, definition.Level) != WarningBehavior.Ignore) + { + definition.Log( + diagnostics, + l => l.LogDebug( + definition.EventId, + null, + definition.MessageFormat, + sequenceName, + sequenceTypeName, + cyclic, + increment, + start, + min, + max)); + } + } + + /// + /// 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. + /// + public static void SequenceNotNamedWarning( + [NotNull] this IDiagnosticsLogger diagnostics) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogSequencesRequireName.Log(diagnostics); + + /// + /// 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. + /// + public static void TableFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogFoundTable.Log(diagnostics, tableName); + + /// + /// 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. + /// + public static void TableSkipped( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogTableNotInSelectionSet.Log(diagnostics, tableName); + + /// + /// 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. + /// + public static void ColumnNotNamedWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogColumnNameEmptyOnTable.Log(diagnostics, tableName); + + /// + /// 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. + /// + public static void ForeignKeyColumnNotNamedWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string foreignKeyName, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqlServerStrings.LogColumnNameEmptyOnForeignKey.Log(diagnostics, tableName, foreignKeyName); } } diff --git a/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs b/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs index 3f85904c7d6..659abee5d53 100644 --- a/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs +++ b/src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs @@ -156,6 +156,231 @@ public static readonly FallbackEventDefinition LogFoundForeignKeyColumn LogLevel.Debug, _resourceManager.GetString("LogFoundForeignKeyColumn")); + /// + /// Found a column on index {indexName} on table {tableName} with an empty or null name. Not including column in index. + /// + public static readonly EventDefinition LogColumnNameEmptyOnIndex + = new EventDefinition( + SqlServerEventId.IndexColumnNotNamedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.IndexColumnNotNamedWarning, + _resourceManager.GetString("LogColumnNameEmptyOnIndex"))); + + /// + /// Column {columnName} belongs to table {tableName} which is not included in the selection set. Skipping. + /// + public static readonly EventDefinition LogColumnNotInSelectionSet + = new EventDefinition( + SqlServerEventId.ColumnSkipped, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqlServerEventId.ColumnSkipped, + _resourceManager.GetString("LogColumnNotInSelectionSet"))); + + /// + /// Foreign key column {columnName} belongs to foreign key {fkName} on table {tableName} which is not included in the selection set. Skipping. + /// + public static readonly EventDefinition LogForeignKeyColumnNotInSelectionSet + = new EventDefinition( + SqlServerEventId.ForeignKeyColumnMissingWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.ForeignKeyColumnMissingWarning, + _resourceManager.GetString("LogForeignKeyColumnNotInSelectionSet"))); + + /// + /// Found a foreign key on table {tableName} with an empty or null name. Skipping foreign key. + /// + public static readonly EventDefinition LogForeignKeyNameEmpty + = new EventDefinition( + SqlServerEventId.ForeignKeyNotNamedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.ForeignKeyNotNamedWarning, + _resourceManager.GetString("LogForeignKeyNameEmpty"))); + + /// + /// Could not scaffold the foreign key '{foreignKeyName}'. The following columns in the foreign key could not be scaffolded: {columnNames}. + /// + public static readonly EventDefinition LogForeignKeyScaffoldErrorPropertyNotFound + = new EventDefinition( + SqlServerEventId.ForeignKeyColumnsNotMappedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.ForeignKeyColumnsNotMappedWarning, + _resourceManager.GetString("LogForeignKeyScaffoldErrorPropertyNotFound"))); + + /// + /// For foreign key {fkName} on table {tableName}, unable to model the end of the foreign key on principal table {principaltableName}. This is usually because the principal table was not included in the selection set. + /// + public static readonly EventDefinition LogPrincipalTableNotInSelectionSet + = new EventDefinition( + SqlServerEventId.ForeignKeyReferencesMissingPrincipalTableWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.ForeignKeyReferencesMissingPrincipalTableWarning, + _resourceManager.GetString("LogPrincipalTableNotInSelectionSet"))); + + /// + /// Found index column on index {indexName} on table {tableName}, column name: {columnName}, ordinal: {ordinal}. + /// + public static readonly EventDefinition LogFoundIndexColumn + = new EventDefinition( + SqlServerEventId.IndexColumnFound, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqlServerEventId.IndexColumnFound, + _resourceManager.GetString("LogFoundIndexColumn"))); + + /// + /// Index column {columnName} belongs to index {indexName} on table {tableName} which is not included in the selection set. Skipping. + /// + public static readonly EventDefinition LogIndexColumnNotInSelectionSet + = new EventDefinition( + SqlServerEventId.IndexColumnSkipped, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.IndexColumnSkipped, + _resourceManager.GetString("LogIndexColumnNotInSelectionSet"))); + + /// + /// Unable to scaffold the index '{indexName}'. The following columns could not be scaffolded: {columnNames}. + /// + public static readonly EventDefinition LogUnableToScaffoldIndexMissingProperty + = new EventDefinition( + SqlServerEventId.IndexColumnsNotMappedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.IndexColumnsNotMappedWarning, + _resourceManager.GetString("LogUnableToScaffoldIndexMissingProperty"))); + + /// + /// Found an index on table {tableName} with an empty or null name. Skipping index. + /// + public static readonly EventDefinition LogIndexNameEmpty + = new EventDefinition( + SqlServerEventId.IndexNotNamedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.IndexNotNamedWarning, + _resourceManager.GetString("LogIndexNameEmpty"))); + + /// + /// For index {indexName}. Unable to find parent table {tableName}. Skipping index. + /// + public static readonly EventDefinition LogUnableToFindTableForIndex + = new EventDefinition( + SqlServerEventId.IndexTableMissingWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.IndexTableMissingWarning, + _resourceManager.GetString("LogUnableToFindTableForIndex"))); + + /// + /// Unable to find a schema in the database matching the selected schema {schema}. + /// + public static readonly EventDefinition LogMissingSchema + = new EventDefinition( + SqlServerEventId.MissingSchemaWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.MissingSchemaWarning, + _resourceManager.GetString("LogMissingSchema"))); + + /// + /// Unable to find a table in the database matching the selected table {table}. + /// + public static readonly EventDefinition LogMissingTable + = new EventDefinition( + SqlServerEventId.MissingTableWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.MissingTableWarning, + _resourceManager.GetString("LogMissingTable"))); + + /// + /// Found sequence name: {name}, data type: {dataType}, cyclic: {isCyclic}, increment: {increment}, start: {start}, minimum: {min}, maximum: {max}. + /// + public static readonly FallbackEventDefinition LogFoundSequence + = new FallbackEventDefinition( + SqlServerEventId.SequenceFound, + LogLevel.Debug, + _resourceManager.GetString("LogFoundSequence")); + + /// + /// Sequence name cannot be null or empty. Entity Framework cannot model a sequence that does not have a name. + /// + public static readonly EventDefinition LogSequencesRequireName + = new EventDefinition( + SqlServerEventId.SequenceNotNamedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.SequenceNotNamedWarning, + _resourceManager.GetString("LogSequencesRequireName"))); + + /// + /// Found table with name: {name}. + /// + public static readonly EventDefinition LogFoundTable + = new EventDefinition( + SqlServerEventId.TableFound, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqlServerEventId.TableFound, + _resourceManager.GetString("LogFoundTable"))); + + /// + /// Table {tableName} is not included in the selection set. Skipping. + /// + public static readonly EventDefinition LogTableNotInSelectionSet + = new EventDefinition( + SqlServerEventId.TableSkipped, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqlServerEventId.TableSkipped, + _resourceManager.GetString("LogTableNotInSelectionSet"))); + + /// + /// Found a column on table {tableName} with an empty or null name. Skipping column. + /// + public static readonly EventDefinition LogColumnNameEmptyOnTable + = new EventDefinition( + SqlServerEventId.ColumnNotNamedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.ColumnNotNamedWarning, + _resourceManager.GetString("LogColumnNameEmptyOnTable"))); + + /// + /// Found a column on foreign key {tableName}.{fkName} with an empty or null name. Not including column in foreign key + /// + public static readonly EventDefinition LogColumnNameEmptyOnForeignKey + = new EventDefinition( + SqlServerEventId.ForeignKeyColumnNotNamedWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqlServerEventId.ForeignKeyColumnNotNamedWarning, + _resourceManager.GetString("LogColumnNameEmptyOnForeignKey"))); + private static string GetString(string name, params string[] formatterNames) { var value = _resourceManager.GetString(name); diff --git a/src/EFCore.SqlServer/Properties/SqlServerStrings.resx b/src/EFCore.SqlServer/Properties/SqlServerStrings.resx index bf1875f165d..aa4201ad989 100644 --- a/src/EFCore.SqlServer/Properties/SqlServerStrings.resx +++ b/src/EFCore.SqlServer/Properties/SqlServerStrings.resx @@ -171,4 +171,80 @@ Found foreign key column with table: {tableName}, foreign key name: {fkName}, principal table: {principalTableName}, column name: {columnName}, principal column name: {principalColumnName}, update action: {updateAction}, delete action: {deleteAction}, ordinal: {ordinal}. Debug SqlServerEventId.ForeignKeyColumnFound string string string string string string string int? + + Found a column on index {indexName} on table {tableName} with an empty or null name. Not including column in index. + Warning SqlServerEventId.IndexColumnNotNamedWarning string string + + + Column {columnName} belongs to table {tableName} which is not included in the selection set. Skipping. + Debug SqlServerEventId.ColumnSkipped string string + + + Foreign key column {columnName} belongs to foreign key {fkName} on table {tableName} which is not included in the selection set. Skipping. + Warning SqlServerEventId.ForeignKeyColumnMissingWarning string string string + + + Found a foreign key on table {tableName} with an empty or null name. Skipping foreign key. + Warning SqlServerEventId.ForeignKeyNotNamedWarning string + + + Could not scaffold the foreign key '{foreignKeyName}'. The following columns in the foreign key could not be scaffolded: {columnNames}. + Warning SqlServerEventId.ForeignKeyColumnsNotMappedWarning string string + + + For foreign key {fkName} on table {tableName}, unable to model the end of the foreign key on principal table {principaltableName}. This is usually because the principal table was not included in the selection set. + Warning SqlServerEventId.ForeignKeyReferencesMissingPrincipalTableWarning string string string + + + Found index column on index {indexName} on table {tableName}, column name: {columnName}, ordinal: {ordinal}. + Debug SqlServerEventId.IndexColumnFound string string string int? + + + Index column {columnName} belongs to index {indexName} on table {tableName} which is not included in the selection set. Skipping. + Warning SqlServerEventId.IndexColumnSkipped string string string + + + Unable to scaffold the index '{indexName}'. The following columns could not be scaffolded: {columnNames}. + Warning SqlServerEventId.IndexColumnsNotMappedWarning string string + + + Found an index on table {tableName} with an empty or null name. Skipping index. + Warning SqlServerEventId.IndexNotNamedWarning string + + + For index {indexName}. Unable to find parent table {tableName}. Skipping index. + Warning SqlServerEventId.IndexTableMissingWarning string string + + + Unable to find a schema in the database matching the selected schema {schema}. + Warning SqlServerEventId.MissingSchemaWarning string + + + Unable to find a table in the database matching the selected table {table}. + Warning SqlServerEventId.MissingTableWarning string + + + Found sequence name: {name}, data type: {dataType}, cyclic: {isCyclic}, increment: {increment}, start: {start}, minimum: {min}, maximum: {max}. + Debug SqlServerEventId.SequenceFound string string bool? int? long? long? long? + + + Sequence name cannot be null or empty. Entity Framework cannot model a sequence that does not have a name. + Warning SqlServerEventId.SequenceNotNamedWarning + + + Found table with name: {name}. + Debug SqlServerEventId.TableFound string + + + Table {tableName} is not included in the selection set. Skipping. + Debug SqlServerEventId.TableSkipped string + + + Found a column on table {tableName} with an empty or null name. Skipping column. + Warning SqlServerEventId.ColumnNotNamedWarning string + + + Found a column on foreign key {tableName}.{fkName} with an empty or null name. Not including column in foreign key + Warning SqlServerEventId.ForeignKeyColumnNotNamedWarning string string + \ No newline at end of file diff --git a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs index 98015e0aeba..5fd46e75614 100644 --- a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs +++ b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs @@ -28,9 +28,16 @@ private enum Id SequenceConfiguredWarning, // Scaffolding events - ColumnFound = CoreEventId.ProviderBaseId + 100, - ForeignKeyColumnFound, - SchemasNotSupportedWarning + ColumnFound = CoreEventId.ProviderDesignBaseId, + ForeignKeyFound, + ForeignKeyPrincipalColumnMissingWarning, + ForeignKeyReferencesMissingTableWarning, + IndexFound, + MissingTableWarning, + PrimaryKeyFound, + SchemasNotSupportedWarning, + TableFound, + UniqueConstraintFound } private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + "."; @@ -72,15 +79,57 @@ private enum Id public static readonly EventId ColumnFound = MakeScaffoldingId(Id.ColumnFound); /// - /// A column of a foreign key was found. + /// SQLite does not support schemas. /// This event is in the category. /// - public static readonly EventId ForeignKeyColumnFound = MakeScaffoldingId(Id.ForeignKeyColumnFound); + public static readonly EventId SchemasNotSupportedWarning = MakeScaffoldingId(Id.SchemasNotSupportedWarning); /// - /// SQLite does not support schemas. + /// A foreign key references a missing table. /// This event is in the category. /// - public static readonly EventId SchemasNotSupportedWarning = MakeScaffoldingId(Id.SchemasNotSupportedWarning); + public static readonly EventId ForeignKeyReferencesMissingTableWarning = MakeScaffoldingId(Id.ForeignKeyReferencesMissingTableWarning); + + /// + /// A table was found. + /// This event is in the category. + /// + public static readonly EventId TableFound = MakeScaffoldingId(Id.TableFound); + + /// + /// The database is missing a table. + /// This event is in the category. + /// + public static readonly EventId MissingTableWarning = MakeScaffoldingId(Id.MissingTableWarning); + + /// + /// A column referenced by a foreign key constraint was not found. + /// This event is in the category. + /// + public static readonly EventId ForeignKeyPrincipalColumnMissingWarning = MakeScaffoldingId(Id.ForeignKeyPrincipalColumnMissingWarning); + + /// + /// An index was found. + /// This event is in the category. + /// + public static readonly EventId IndexFound = MakeScaffoldingId(Id.IndexFound); + + /// + /// A foreign key was found. + /// This event is in the category. + /// + public static readonly EventId ForeignKeyFound = MakeScaffoldingId(Id.ForeignKeyFound); + + /// + /// A primary key was found. + /// This event is in the category. + /// + public static readonly EventId PrimaryKeyFound = MakeScaffoldingId(Id.PrimaryKeyFound); + + /// + /// A unique constraint was found. + /// This event is in the category. + /// + public static readonly EventId UniqueConstraintFound = MakeScaffoldingId(Id.UniqueConstraintFound); } } diff --git a/src/EFCore.Sqlite.Core/Internal/SqliteLoggerExtensions.cs b/src/EFCore.Sqlite.Core/Internal/SqliteLoggerExtensions.cs index 2406b4d893f..b1b926ca158 100644 --- a/src/EFCore.Sqlite.Core/Internal/SqliteLoggerExtensions.cs +++ b/src/EFCore.Sqlite.Core/Internal/SqliteLoggerExtensions.cs @@ -1,12 +1,10 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Diagnostics; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.Extensions.Logging; namespace Microsoft.EntityFrameworkCore.Internal { @@ -91,72 +89,106 @@ public static void ColumnFound( [CanBeNull] string dataTypeName, bool notNull, [CanBeNull] string defaultValue) - { // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogFoundColumn.Log(diagnostics, tableName, columnName, dataTypeName, notNull, defaultValue); - var definition = SqliteStrings.LogFoundColumn; + /// + /// 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. + /// + public static void SchemasNotSupportedWarning( + [NotNull] this IDiagnosticsLogger diagnostics) + // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogUsingSchemaSelectionsWarning.Log(diagnostics); - Debug.Assert(LogLevel.Debug == definition.Level); + /// + /// 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. + /// + public static void ForeignKeyReferencesMissingTableWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string foreignKeyName) + // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogForeignKeyScaffoldErrorPrincipalTableNotFound.Log(diagnostics, foreignKeyName); - if (diagnostics.GetLogBehavior(definition.EventId, definition.Level) != WarningBehavior.Ignore) - { - definition.Log( - diagnostics, - l => l.LogDebug( - definition.EventId, - null, - definition.MessageFormat, - tableName, - columnName, - dataTypeName, - notNull, - defaultValue)); - } - } + /// + /// 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. + /// + public static void TableFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogFoundTable.Log(diagnostics, tableName); /// /// 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. /// - public static void ForeignKeyColumnFound( + public static void MissingTableWarning( [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogMissingTable.Log(diagnostics, tableName); + + /// + /// 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. + /// + public static void ForeignKeyPrincipalColumnMissingWarning( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string foreignKeyName, [CanBeNull] string tableName, - long id, - [CanBeNull] string principalTableName, - [CanBeNull] string columnName, [CanBeNull] string principalColumnName, - [CanBeNull] string deleteAction) - { + [CanBeNull] string principalTableName) // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogPrincipalColumnNotFound.Log(diagnostics, foreignKeyName, tableName, principalColumnName, principalTableName); - var definition = SqliteStrings.LogFoundForeignKeyColumn; + /// + /// 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. + /// + public static void IndexFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string indexName, + [CanBeNull] string tableName, + bool? unique) + // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogFoundIndex.Log(diagnostics, indexName, tableName, unique); - Debug.Assert(LogLevel.Debug == definition.Level); + /// + /// 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. + /// + public static void ForeignKeyFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string tableName, + long id, + [CanBeNull] string principalTableName, + [CanBeNull] string deleteAction) + // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogFoundForeignKey.Log(diagnostics, tableName, id, principalTableName, deleteAction); - if (diagnostics.GetLogBehavior(definition.EventId, definition.Level) != WarningBehavior.Ignore) - { - definition.Log( - diagnostics, - l => l.LogDebug( - definition.EventId, - null, - definition.MessageFormat, - tableName, - id, - principalTableName, - columnName, - principalColumnName, - deleteAction)); - } - } + /// + /// 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. + /// + public static void PrimaryKeyFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string primaryKeyName, + [CanBeNull] string tableName) + // No DiagnosticsSource events because these are purely design-time messages + => SqliteStrings.LogFoundPrimaryKey.Log(diagnostics, primaryKeyName, tableName); /// /// 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. /// - public static void SchemasNotSupportedWarning( - [NotNull] this IDiagnosticsLogger diagnostics) + public static void UniqueConstraintFound( + [NotNull] this IDiagnosticsLogger diagnostics, + [CanBeNull] string uniqueConstraintName, + [CanBeNull] string tableName) // No DiagnosticsSource events because these are purely design-time messages - => SqliteStrings.LogUsingSchemaSelectionsWarning.Log(diagnostics); + => SqliteStrings.LogFoundUniqueConstraint.Log(diagnostics, uniqueConstraintName, tableName); } } diff --git a/src/EFCore.Sqlite.Core/Properties/SqliteStrings.Designer.cs b/src/EFCore.Sqlite.Core/Properties/SqliteStrings.Designer.cs index 371894f50cd..b100049f8c6 100644 --- a/src/EFCore.Sqlite.Core/Properties/SqliteStrings.Designer.cs +++ b/src/EFCore.Sqlite.Core/Properties/SqliteStrings.Designer.cs @@ -77,20 +77,110 @@ public static readonly EventDefinition LogUsingSchemaSelectionsWarning /// /// Found column on table: {tableName}, column name: {columnName}, data type: {dataType}, not nullable: {isNotNullable}, default value: {defaultValue}. /// - public static readonly FallbackEventDefinition LogFoundColumn - = new FallbackEventDefinition( + public static readonly EventDefinition LogFoundColumn + = new EventDefinition( SqliteEventId.ColumnFound, LogLevel.Debug, - _resourceManager.GetString("LogFoundColumn")); + LoggerMessage.Define( + LogLevel.Debug, + SqliteEventId.ColumnFound, + _resourceManager.GetString("LogFoundColumn"))); /// - /// Found foreign key column on table: {tableName}, id: {id}, principal table: {principalTableName}, column name: {columnName}, principal column name: {principalColumnName}, delete action: {deleteAction}. + /// Found foreign key on table: {tableName}, id: {id}, principal table: {principalTableName}, delete action: {deleteAction}. /// - public static readonly FallbackEventDefinition LogFoundForeignKeyColumn - = new FallbackEventDefinition( - SqliteEventId.ForeignKeyColumnFound, + public static readonly EventDefinition LogFoundForeignKey + = new EventDefinition( + SqliteEventId.ForeignKeyFound, LogLevel.Debug, - _resourceManager.GetString("LogFoundForeignKeyColumn")); + LoggerMessage.Define( + LogLevel.Debug, + SqliteEventId.ForeignKeyFound, + _resourceManager.GetString("LogFoundForeignKey"))); + + /// + /// Could not scaffold the foreign key '{foreignKeyName}'. The referenced table could not be found. This most likely occurred because the referenced table was excluded from scaffolding. + /// + public static readonly EventDefinition LogForeignKeyScaffoldErrorPrincipalTableNotFound + = new EventDefinition( + SqliteEventId.ForeignKeyReferencesMissingTableWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqliteEventId.ForeignKeyReferencesMissingTableWarning, + _resourceManager.GetString("LogForeignKeyScaffoldErrorPrincipalTableNotFound"))); + + /// + /// Found table with name: {name}. + /// + public static readonly EventDefinition LogFoundTable + = new EventDefinition( + SqliteEventId.TableFound, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqliteEventId.TableFound, + _resourceManager.GetString("LogFoundTable"))); + + /// + /// Unable to find a table in the database matching the selected table {table}. + /// + public static readonly EventDefinition LogMissingTable + = new EventDefinition( + SqliteEventId.MissingTableWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqliteEventId.MissingTableWarning, + _resourceManager.GetString("LogMissingTable"))); + + /// + /// For foreign key with identity {id} on table {tableName}, unable to find the column called {principalColumnName} on the foreign key's principal table, {principaltableName}. Skipping foreign key. + /// + public static readonly EventDefinition LogPrincipalColumnNotFound + = new EventDefinition( + SqliteEventId.ForeignKeyPrincipalColumnMissingWarning, + LogLevel.Warning, + LoggerMessage.Define( + LogLevel.Warning, + SqliteEventId.ForeignKeyPrincipalColumnMissingWarning, + _resourceManager.GetString("LogPrincipalColumnNotFound"))); + + /// + /// Found index with name: {indexName}, table: {tableName}, is unique: {isUnique}. + /// + public static readonly EventDefinition LogFoundIndex + = new EventDefinition( + SqliteEventId.IndexFound, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqliteEventId.IndexFound, + _resourceManager.GetString("LogFoundIndex"))); + + /// + /// Found primary key with name: {primaryKeyName}, table: {tableName}. + /// + public static readonly EventDefinition LogFoundPrimaryKey + = new EventDefinition( + SqliteEventId.PrimaryKeyFound, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqliteEventId.PrimaryKeyFound, + _resourceManager.GetString("LogFoundPrimaryKey"))); + + /// + /// Found unique constraint with name: {uniqueConstraintName}, table: {tableName}. + /// + public static readonly EventDefinition LogFoundUniqueConstraint + = new EventDefinition( + SqliteEventId.UniqueConstraintFound, + LogLevel.Debug, + LoggerMessage.Define( + LogLevel.Debug, + SqliteEventId.UniqueConstraintFound, + _resourceManager.GetString("LogFoundUniqueConstraint"))); private static string GetString(string name, params string[] formatterNames) { diff --git a/src/EFCore.Sqlite.Core/Properties/SqliteStrings.resx b/src/EFCore.Sqlite.Core/Properties/SqliteStrings.resx index 61bd6a187d5..fc41f3dccdb 100644 --- a/src/EFCore.Sqlite.Core/Properties/SqliteStrings.resx +++ b/src/EFCore.Sqlite.Core/Properties/SqliteStrings.resx @@ -142,8 +142,36 @@ Found column on table: {tableName}, column name: {columnName}, data type: {dataType}, not nullable: {isNotNullable}, default value: {defaultValue}. Debug SqliteEventId.ColumnFound string string string bool string - - Found foreign key column on table: {tableName}, id: {id}, principal table: {principalTableName}, column name: {columnName}, principal column name: {principalColumnName}, delete action: {deleteAction}. - Debug SqliteEventId.ForeignKeyColumnFound string long string string string string + + Found foreign key on table: {tableName}, id: {id}, principal table: {principalTableName}, delete action: {deleteAction}. + Debug SqliteEventId.ForeignKeyFound string long string string + + + Could not scaffold the foreign key '{foreignKeyName}'. The referenced table could not be found. This most likely occurred because the referenced table was excluded from scaffolding. + Warning SqliteEventId.ForeignKeyReferencesMissingTableWarning string + + + Found table with name: {name}. + Debug SqliteEventId.TableFound string + + + Unable to find a table in the database matching the selected table {table}. + Warning SqliteEventId.MissingTableWarning string + + + For foreign key with identity {id} on table {tableName}, unable to find the column called {principalColumnName} on the foreign key's principal table, {principaltableName}. Skipping foreign key. + Warning SqliteEventId.ForeignKeyPrincipalColumnMissingWarning string string string string + + + Found index with name: {indexName}, table: {tableName}, is unique: {isUnique}. + Debug SqliteEventId.IndexFound string string bool? + + + Found primary key with name: {primaryKeyName}, table: {tableName}. + Debug SqliteEventId.PrimaryKeyFound string string + + + Found unique constraint with name: {uniqueConstraintName}, table: {tableName}. + Debug SqliteEventId.UniqueConstraintFound string string \ No newline at end of file diff --git a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs index aa0562480ac..29d31adb9f0 100644 --- a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs +++ b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs @@ -147,44 +147,41 @@ private IEnumerable GetTables(DbConnection connection, IEnumerabl while (reader.Read()) { var name = reader.GetString(0); - - _logger.TableFound(name); - - if (tableSelectionSet.Allows(name)) + if (!tableSelectionSet.Allows(name)) { - var table = new DatabaseTable { Name = name }; + continue; + } - foreach (var column in GetColumns(connection, name)) - { - column.Table = table; - table.Columns.Add(column); - } + _logger.TableFound(name); - var primaryKey = GetPrimaryKey(connection, name, table.Columns); - if (primaryKey != null) - { - primaryKey.Table = table; - table.PrimaryKey = primaryKey; - } + var table = new DatabaseTable { Name = name }; - foreach (var uniqueConstraints in GetUniqueConstraints(connection, name, table.Columns)) - { - uniqueConstraints.Table = table; - table.UniqueConstraints.Add(uniqueConstraints); - } + foreach (var column in GetColumns(connection, name)) + { + column.Table = table; + table.Columns.Add(column); + } - foreach (var index in GetIndexes(connection, name, table.Columns)) - { - index.Table = table; - table.Indexes.Add(index); - } + var primaryKey = GetPrimaryKey(connection, name, table.Columns); + if (primaryKey != null) + { + primaryKey.Table = table; + table.PrimaryKey = primaryKey; + } - yield return table; + foreach (var uniqueConstraints in GetUniqueConstraints(connection, name, table.Columns)) + { + uniqueConstraints.Table = table; + table.UniqueConstraints.Add(uniqueConstraints); } - else + + foreach (var index in GetIndexes(connection, name, table.Columns)) { - _logger.TableSkipped(name); + index.Table = table; + table.Indexes.Add(index); } + + yield return table; } } @@ -259,7 +256,7 @@ private DatabasePrimaryKey GetPrimaryKey(DbConnection connection, string table, primaryKey.Name = name; } - _logger.IndexFound(name, table, unique: true); + _logger.PrimaryKeyFound(name, table); command.CommandText = new StringBuilder() .AppendLine("SELECT \"name\"") @@ -279,8 +276,6 @@ private DatabasePrimaryKey GetPrimaryKey(DbConnection connection, string table, ?? columns.FirstOrDefault(c => c.Name.Equals(columnName, StringComparison.OrdinalIgnoreCase)); Debug.Assert(column != null, "column is null."); - _logger.IndexColumnFound(table, name, true, columnName, null); - primaryKey.Columns.Add(column); } } @@ -352,7 +347,7 @@ private IEnumerable GetUniqueConstraints( uniqueConstraint.Name = name; } - _logger.IndexFound(name, table, unique: true); + _logger.UniqueConstraintFound(name, table); var command2 = connection.CreateCommand(); command2.CommandText = new StringBuilder() @@ -375,8 +370,6 @@ private IEnumerable GetUniqueConstraints( ?? columns.FirstOrDefault(c => c.Name.Equals(columnName, StringComparison.OrdinalIgnoreCase)); Debug.Assert(column != null, "column is null."); - _logger.IndexColumnFound(table, name, true, columnName, null); - uniqueConstraint.Columns.Add(column); } } @@ -437,8 +430,6 @@ private IEnumerable GetIndexes( ?? columns.FirstOrDefault(c => c.Name.Equals(name, StringComparison.Ordinal)); Debug.Assert(column != null, "column is null."); - _logger.IndexColumnFound(table, index.Name, index.IsUnique, name, null); - index.Columns.Add(column); } } @@ -468,13 +459,16 @@ private IEnumerable GetForeignKeys(DbConnection connection, { var id = reader1.GetInt64(0); var principalTableName = reader1.GetString(1); + var onDelete = reader1.GetString(2); var foreignKey = new DatabaseForeignKey { PrincipalTable = tables.FirstOrDefault(t => t.Name == principalTableName) ?? tables.FirstOrDefault(t => t.Name.Equals(principalTableName, StringComparison.OrdinalIgnoreCase)), - OnDelete = ConvertToReferentialAction(reader1.GetString(2)) + OnDelete = ConvertToReferentialAction(onDelete) }; + _logger.ForeignKeyFound(table.Name, id, principalTableName, onDelete); + if (foreignKey.PrincipalTable == null) { _logger.ForeignKeyReferencesMissingTableWarning(id.ToString()); @@ -521,14 +515,6 @@ private IEnumerable GetForeignKeys(DbConnection connection, break; } - _logger.ForeignKeyColumnFound( - table.Name, - id, - principalTableName, - columnName, - principalColumnName, - foreignKey.OnDelete?.ToString()); - foreignKey.Columns.Add(column); foreignKey.PrincipalColumns.Add(principalColumn); } diff --git a/src/EFCore/Diagnostics/CoreEventId.cs b/src/EFCore/Diagnostics/CoreEventId.cs index 7910d6ecede..b49c12f1cbd 100644 --- a/src/EFCore/Diagnostics/CoreEventId.cs +++ b/src/EFCore/Diagnostics/CoreEventId.cs @@ -23,11 +23,6 @@ public static class CoreEventId /// public const int CoreBaseId = 100000; - /// - /// The lower-bound for event IDs used by any Entity Framework or provider code design-time and tooling. - /// - public const int CoreDesignBaseId = 150000; - /// /// The lower-bound for event IDs used by any relational database provider. /// diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs index 94455f8e97d..1e020afa6be 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/RelationalScaffoldingModelFactoryTest.cs @@ -4,12 +4,10 @@ using System; using System.Collections.Generic; using System.Data.Common; -using System.Diagnostics; using System.Linq; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Design; using Microsoft.EntityFrameworkCore.Design.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Metadata.Internal; @@ -20,7 +18,6 @@ using Microsoft.EntityFrameworkCore.Scaffolding.Metadata.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.Extensions.Logging; using Xunit; namespace Microsoft.EntityFrameworkCore @@ -28,20 +25,15 @@ namespace Microsoft.EntityFrameworkCore public class RelationalDatabaseModelFactoryTest { private readonly FakeScaffoldingModelFactory _factory; - private readonly TestDesignLoggerFactory.DesignLogger _logger; + private readonly TestOperationReporter _reporter; private static DatabaseColumn IdColumn => new DatabaseColumn { Name = "Id", StoreType = "long" }; private static DatabasePrimaryKey IdPrimaryKey = new DatabasePrimaryKey { Columns = { IdColumn } }; public RelationalDatabaseModelFactoryTest() { - ILoggerFactory loggerFactory = new TestDesignLoggerFactory(); - _logger = (TestDesignLoggerFactory.DesignLogger)loggerFactory.CreateLogger(DbLoggerCategory.Scaffolding.Name); - - _factory = new FakeScaffoldingModelFactory( - new DiagnosticsLogger( - loggerFactory, - new LoggingOptions(), - new DiagnosticListener("Fake"))); + _reporter = new TestOperationReporter(); + + _factory = new FakeScaffoldingModelFactory(_reporter); } [Fact] @@ -285,7 +277,7 @@ public void Unmappable_column_type(string StoreType) }); Assert.Single(_factory.Create(info).FindEntityType("E").GetProperties()); - Assert.Single(_logger.Statements, t => t.Contains(DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("E.Coli", StoreType))); + Assert.Single(_reporter.Messages, t => t.Contains(DesignStrings.CannotFindTypeMappingForColumn("E.Coli", StoreType))); } [Theory] @@ -606,9 +598,9 @@ public void It_logs_warning_for_bad_foreign_key() _factory.Create(new DatabaseModel { Tables = { parentTable, childrenTable } }); Assert.Single( - _logger.Statements, t => t.Contains( - "Warning: " + - DesignStrings.LogForeignKeyScaffoldErrorPrincipalKeyNotFound.GenerateMessage( + _reporter.Messages, t => t.Contains( + "warn: " + + DesignStrings.ForeignKeyScaffoldErrorPrincipalKeyNotFound( childrenTable.ForeignKeys.ElementAt(0).DisplayName(), "NotPkId", "Parent"))); } @@ -695,9 +687,9 @@ public void Unique_nullable_index_used_by_foreign_key() Assert.Equal(alternateKey, fk.PrincipalKey); Assert.Single( - _logger.Statements, t => t.Contains( - "Warning: " + - DesignStrings.LogForeignKeyPrincipalEndContainsNullableColumns.GenerateMessage( + _reporter.Messages, t => t.Contains( + "warn: " + + DesignStrings.ForeignKeyPrincipalEndContainsNullableColumns( table.ForeignKeys.ElementAt(0).DisplayName(), "FriendsNameUniqueIndex", "Friends.BuddyId"))); } @@ -895,10 +887,7 @@ public void Pluralization_of_entity_and_DbSet() }; var factory = new FakeScaffoldingModelFactory( - new DiagnosticsLogger( - new TestDesignLoggerFactory(), - new LoggingOptions(), - new DiagnosticListener("Fake")), + new TestOperationReporter(), new FakePluralizer()); var model = factory.Create(info); @@ -951,10 +940,7 @@ public void Pluralization_of_collection_navigations() }; var factory = new FakeScaffoldingModelFactory( - new DiagnosticsLogger( - new TestDesignLoggerFactory(), - new LoggingOptions(), - new DiagnosticListener("Fake")), + new TestOperationReporter(), new FakePluralizer()); var model = factory.Create(info); @@ -1018,16 +1004,16 @@ public IModel Create(DatabaseModel databaseModel) } public FakeScaffoldingModelFactory( - [NotNull] IDiagnosticsLogger logger) - : this(logger, new NullPluralizer()) + [NotNull] IOperationReporter reporter) + : this(reporter, new NullPluralizer()) { } public FakeScaffoldingModelFactory( - [NotNull] IDiagnosticsLogger logger, + [NotNull] IOperationReporter reporter, [NotNull] IPluralizer pluralizer) : base( - logger, + reporter, new TestTypeMapper(new RelationalTypeMapperDependencies()), new FakeDatabaseModelFactory(), new CandidateNamingService(), diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs index d8d24fda592..a31c9273855 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/ReverseEngineeringConfigurationTests.cs @@ -28,7 +28,7 @@ private void ValidateContextNameInReverseEngineerGenerator(string contextName) { var cSharpUtilities = new CSharpUtilities(); var reverseEngineer = new ModelScaffolder( - new FakeScaffoldingModelFactory(new FakeDiagnosticsLogger()), + new FakeScaffoldingModelFactory(new TestOperationReporter()), new CSharpScaffoldingGenerator( new InMemoryFileService(), new CSharpDbContextGenerator(new FakeScaffoldingCodeGenerator(), new FakeAnnotationCodeGenerator(), cSharpUtilities), diff --git a/test/EFCore.SqlServer.Design.FunctionalTests/ReverseEngineering/SqlServerE2ETests.cs b/test/EFCore.SqlServer.Design.FunctionalTests/ReverseEngineering/SqlServerE2ETests.cs index 4462baf6f15..f970aabda94 100644 --- a/test/EFCore.SqlServer.Design.FunctionalTests/ReverseEngineering/SqlServerE2ETests.cs +++ b/test/EFCore.SqlServer.Design.FunctionalTests/ReverseEngineering/SqlServerE2ETests.cs @@ -108,24 +108,15 @@ public void E2ETest_UseAttributesInsteadOfFluentApi() .Concat(_expectedEntityTypeFiles).ToList() }; - var indexWarn = _reporter.Messages.Warn.Single(m => m.Contains("PK__Filtered__")); - - AssertLog(new LoggerMessages - { - Warn = - { - indexWarn, - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.geographyColumn", "geography"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.geometryColumn", "geometry"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.sql_variantColumn", "sql_variant"), - RelationalStrings.LogUnableToScaffoldIndexMissingProperty.GenerateMessage("IX_UnscaffoldableIndex", "sql_variantColumn,hierarchyidColumn"), - //SqlServerDesignStrings.LogDataTypeDoesNotAllowSqlServerIdentityStrategy.GenerateMessage("dbo.PropertyConfiguration.PropertyConfigurationID", "tinyint"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"), - DesignStrings.LogPrimaryKeyErrorPropertyNotFound.GenerateMessage("dbo.TableWithUnmappablePrimaryKeyColumn", "TableWithUnmappablePrimaryKeyColumnID"), - DesignStrings.LogUnableToGenerateEntityType.GenerateMessage("dbo.TableWithUnmappablePrimaryKeyColumn") - } - }); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.geographyColumn", "geography"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.geometryColumn", "geometry"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.sql_variantColumn", "sql_variant"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.UnableToScaffoldIndexMissingProperty("IX_UnscaffoldableIndex", "sql_variantColumn,hierarchyidColumn"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.PrimaryKeyErrorPropertyNotFound("dbo.TableWithUnmappablePrimaryKeyColumn", "TableWithUnmappablePrimaryKeyColumnID"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.UnableToGenerateEntityType("dbo.TableWithUnmappablePrimaryKeyColumn"), _reporter.Messages); + Assert.Equal(8, _reporter.Messages.Count); AssertEqualFileContents(expectedFileSet, actualFileSet); AssertCompile(actualFileSet); } @@ -158,24 +149,15 @@ public void E2ETest_AllFluentApi() .Concat(_expectedEntityTypeFiles).ToList() }; - var indexWarn = _reporter.Messages.Warn.Single(m => m.Contains("PK__Filtered__")); - - AssertLog(new LoggerMessages - { - Warn = - { - indexWarn, - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.geographyColumn", "geography"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.geometryColumn", "geometry"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.AllDataTypes.sql_variantColumn", "sql_variant"), - RelationalStrings.LogUnableToScaffoldIndexMissingProperty.GenerateMessage("IX_UnscaffoldableIndex", "sql_variantColumn,hierarchyidColumn"), - //SqlServerDesignStrings.LogDataTypeDoesNotAllowSqlServerIdentityStrategy.GenerateMessage("dbo.PropertyConfiguration.PropertyConfigurationID", "tinyint"), - DesignStrings.LogCannotFindTypeMappingForColumn.GenerateMessage("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"), - DesignStrings.LogPrimaryKeyErrorPropertyNotFound.GenerateMessage("dbo.TableWithUnmappablePrimaryKeyColumn", "TableWithUnmappablePrimaryKeyColumnID"), - DesignStrings.LogUnableToGenerateEntityType.GenerateMessage("dbo.TableWithUnmappablePrimaryKeyColumn") - } - }); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.geographyColumn", "geography"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.geometryColumn", "geometry"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.sql_variantColumn", "sql_variant"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.UnableToScaffoldIndexMissingProperty("IX_UnscaffoldableIndex", "sql_variantColumn,hierarchyidColumn"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.CannotFindTypeMappingForColumn("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.PrimaryKeyErrorPropertyNotFound("dbo.TableWithUnmappablePrimaryKeyColumn", "TableWithUnmappablePrimaryKeyColumnID"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.UnableToGenerateEntityType("dbo.TableWithUnmappablePrimaryKeyColumn"), _reporter.Messages); + Assert.Equal(8, _reporter.Messages.Count); AssertEqualFileContents(expectedFileSet, actualFileSet); AssertCompile(actualFileSet); } @@ -221,13 +203,8 @@ BoolWithoutDefaultValueSql bit NOT NULL Files = new[] { filePaths.ContextFile }.Concat(filePaths.EntityTypeFiles).Select(Path.GetFileName).ToList() }; - AssertLog(new LoggerMessages - { - Warn = - { - DesignStrings.LogNonNullableBoooleanColumnHasDefaultConstraint.GenerateMessage("dbo.NonNullBoolWithDefault.BoolWithDefaultValueSql") - } - }); + Assert.Contains("warn: " + DesignStrings.NonNullableBoooleanColumnHasDefaultConstraint("dbo.NonNullBoolWithDefault.BoolWithDefaultValueSql"), _reporter.Messages); + Assert.Equal(1, _reporter.Messages.Count); AssertEqualFileContents(expectedFileSet, actualFileSet); AssertCompile(actualFileSet); @@ -295,14 +272,9 @@ CREATE SEQUENCE NumericSequence Files = new[] { filePaths.ContextFile }.Concat(filePaths.EntityTypeFiles).Select(Path.GetFileName).ToList() }; - AssertLog(new LoggerMessages - { - Warn = - { - DesignStrings.LogBadSequenceType.GenerateMessage("DecimalSequence", "decimal"), - DesignStrings.LogBadSequenceType.GenerateMessage("NumericSequence", "numeric") - } - }); + Assert.Contains("warn: " + DesignStrings.BadSequenceType("DecimalSequence", "decimal"), _reporter.Messages); + Assert.Contains("warn: " + DesignStrings.BadSequenceType("NumericSequence", "numeric"), _reporter.Messages); + Assert.Equal(2, _reporter.Messages.Count); AssertEqualFileContents(expectedFileSet, actualFileSet); AssertCompile(actualFileSet); diff --git a/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs b/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs index 9eefd2d8685..dcaeafb50f8 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerEventIdTest.cs @@ -22,6 +22,7 @@ public void Every_eventId_has_a_logger_method_and_logs_when_level_enabled() var fakeFactories = new Dictionary> { + { typeof(IList), () => new List { "Fake1", "Fake2" } }, { typeof(IProperty), () => property }, { typeof(string), () => "Fake" } }; diff --git a/test/EFCore.Sqlite.Design.FunctionalTests/ReverseEngineering/SqliteE2ETestBase.cs b/test/EFCore.Sqlite.Design.FunctionalTests/ReverseEngineering/SqliteE2ETestBase.cs index e32967eadf4..487844cdd59 100644 --- a/test/EFCore.Sqlite.Design.FunctionalTests/ReverseEngineering/SqliteE2ETestBase.cs +++ b/test/EFCore.Sqlite.Design.FunctionalTests/ReverseEngineering/SqliteE2ETestBase.cs @@ -52,7 +52,7 @@ FOREIGN KEY (PrincipalId) REFERENCES Principal (Id) useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - AssertLog(new LoggerMessages()); + Assert.Empty(_reporter.Messages); var expectedFileSet = new FileSet(new FileSystemFileService(), Path.Combine(ExpectedResultsParentDir, "OneToOne")) { @@ -107,7 +107,7 @@ REFERENCES OneToManyPrincipal ( OneToManyPrincipalID1, OneToManyPrincipalID2 ) useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - AssertLog(new LoggerMessages()); + Assert.Empty(_reporter.Messages); var expectedFileSet = new FileSet(new FileSystemFileService(), Path.Combine(ExpectedResultsParentDir, "OneToMany")) { @@ -156,7 +156,7 @@ FOREIGN KEY (GroupId) REFERENCES Groups (Id) useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - AssertLog(new LoggerMessages()); + Assert.Empty(_reporter.Messages); var expectedFileSet = new FileSet(new FileSystemFileService(), Path.Combine(ExpectedResultsParentDir, "ManyToMany")) { @@ -199,7 +199,7 @@ FOREIGN KEY (SelfForeignKey) REFERENCES SelfRef (Id) useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - AssertLog(new LoggerMessages()); + Assert.Empty(_reporter.Messages); var expectedFileSet = new FileSet(new FileSystemFileService(), Path.Combine(ExpectedResultsParentDir, "SelfRef")) { @@ -236,16 +236,11 @@ public void Missing_primary_key() useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - var errorMessage = DesignStrings.LogUnableToGenerateEntityType.GenerateMessage("Alicia"); - var expectedLog = new LoggerMessages - { - Warn = - { - DesignStrings.LogMissingPrimaryKey.GenerateMessage("Alicia"), - errorMessage - } - }; - AssertLog(expectedLog); + var errorMessage = DesignStrings.UnableToGenerateEntityType("Alicia"); + Assert.Collection( + _reporter.Messages, + x => Assert.Equal("warn: " + DesignStrings.MissingPrimaryKey("Alicia"), x), + x => Assert.Equal("warn: " + errorMessage, x)); Assert.Contains(errorMessage, InMemoryFiles.RetrieveFileContents(TestProjectFullPath, Path.GetFileName(results.ContextFile))); } } @@ -273,16 +268,11 @@ FOREIGN KEY (PrincipalId) REFERENCES Principal(Id) useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - var expectedLog = new LoggerMessages - { - Warn = - { - DesignStrings.LogMissingPrimaryKey.GenerateMessage("Principal"), - DesignStrings.LogUnableToGenerateEntityType.GenerateMessage("Principal"), - DesignStrings.LogForeignKeyScaffoldErrorPrincipalTableScaffoldingError.GenerateMessage("Dependent(PrincipalId)", "Principal") - } - }; - AssertLog(expectedLog); + Assert.Collection( + _reporter.Messages, + x => Assert.Equal("warn: " + DesignStrings.MissingPrimaryKey("Principal"), x), + x => Assert.Equal("warn: " + DesignStrings.UnableToGenerateEntityType("Principal"), x), + x => Assert.Equal("warn: " + DesignStrings.ForeignKeyScaffoldErrorPrincipalTableScaffoldingError("Dependent(PrincipalId)", "Principal"), x)); var expectedFileSet = new FileSet(new FileSystemFileService(), Path.Combine(ExpectedResultsParentDir, "NoPrincipalPk")) { @@ -342,7 +332,7 @@ FOREIGN KEY (string) REFERENCES String (string) useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - AssertLog(new LoggerMessages()); + Assert.Empty(_reporter.Messages); var files = new FileSet(InMemoryFiles, TestProjectFullPath) { @@ -380,7 +370,7 @@ FOREIGN KEY (UserAltId) REFERENCES User (AltId) useDataAnnotations: UseDataAnnotations, overwriteFiles: false); - AssertLog(new LoggerMessages()); + Assert.Empty(_reporter.Messages); var expectedFileSet = new FileSet(new FileSystemFileService(), Path.Combine(ExpectedResultsParentDir, "FkToAltKey")) { diff --git a/test/EFCore.Sqlite.Design.FunctionalTests/SqliteDatabaseModelFactoryTest.cs b/test/EFCore.Sqlite.Design.FunctionalTests/SqliteDatabaseModelFactoryTest.cs index 3db485f5a9a..edaa00d828d 100644 --- a/test/EFCore.Sqlite.Design.FunctionalTests/SqliteDatabaseModelFactoryTest.cs +++ b/test/EFCore.Sqlite.Design.FunctionalTests/SqliteDatabaseModelFactoryTest.cs @@ -27,7 +27,8 @@ public SqliteDatabaseModelFactoryTest() var serviceCollection = new ServiceCollection().AddScaffolding() .AddLogging() - .AddSingleton(new TestDesignLoggerFactory()); + .AddSingleton(new TestDesignLoggerFactory()) + .AddSingleton(); new SqliteDesignTimeServices().ConfigureDesignTimeServices(serviceCollection); var serviceProvider = serviceCollection.BuildServiceProvider(); diff --git a/test/EFCore.Sqlite.Design.FunctionalTests/SqliteScaffoldingModelFactoryTest.cs b/test/EFCore.Sqlite.Design.FunctionalTests/SqliteScaffoldingModelFactoryTest.cs index 1e02c4a9d78..754d4dc29b7 100644 --- a/test/EFCore.Sqlite.Design.FunctionalTests/SqliteScaffoldingModelFactoryTest.cs +++ b/test/EFCore.Sqlite.Design.FunctionalTests/SqliteScaffoldingModelFactoryTest.cs @@ -26,7 +26,8 @@ public SqliteScaffoldingModelFactoryTest() { _testStore = SqliteTestStore.CreateScratch(); - var serviceCollection = new ServiceCollection().AddScaffolding().AddLogging(); + var serviceCollection = new ServiceCollection().AddScaffolding().AddLogging() + .AddSingleton(); new SqliteDesignTimeServices().ConfigureDesignTimeServices(serviceCollection); var serviceProvider = serviceCollection @@ -207,7 +208,7 @@ FOREIGN KEY (ParentId) REFERENCES Parent (Id) _loggerFactory.Logger.Statements, t => t.Contains( "Warning: " + - RelationalStrings.LogForeignKeyScaffoldErrorPrincipalTableNotFound.GenerateMessage("0"))); + SqliteStrings.LogForeignKeyScaffoldErrorPrincipalTableNotFound.GenerateMessage("0"))); } [Fact] @@ -227,7 +228,7 @@ FOREIGN KEY (ParentId) REFERENCES Parent (Id) _loggerFactory.Logger.Statements, t => t.Contains( "Warning: " + - RelationalStrings.LogPrincipalColumnNotFound.GenerateMessage("0", "Children", "Id", "Parent"))); + SqliteStrings.LogPrincipalColumnNotFound.GenerateMessage("0", "Children", "Id", "Parent"))); } [Fact]