Skip to content

Commit

Permalink
More precise index scaffolding warning
Browse files Browse the repository at this point in the history
Missing property is only one reason for failing to scaffold an index.
Providers may override VisitIndex and return null for other reasons, in
which case it's their responsibility to log a warning.
  • Loading branch information
roji committed Dec 9, 2015
1 parent af876fa commit 503095e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<data name="UnableToGenerateEntityType" xml:space="preserve">
<value>Unable to generate entity type for table '{tableName}'.</value>
</data>
<data name="UnableToScaffoldIndex" xml:space="preserve">
<data name="UnableToScaffoldIndexMissingProperty" xml:space="preserve">
<value>Unable to scaffold the index '{indexName}' because at least one of the properties it contains could not be scaffolded.</value>
</data>
<data name="MissingUseProviderMethodNameAnnotation" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,7 @@ protected virtual EntityTypeBuilder VisitIndexes([NotNull] EntityTypeBuilder bui

foreach (var index in indexes)
{
var indexBuilder = VisitIndex(builder, index);

if (indexBuilder == null)
{
Logger.LogWarning(RelationalDesignStrings.UnableToScaffoldIndex(index.Name));
}
VisitIndex(builder, index);
}

return builder;
Expand All @@ -283,7 +278,7 @@ protected virtual IndexBuilder VisitIndex([NotNull] EntityTypeBuilder builder, [

if (properties.Count(p => builder.Metadata.FindProperty(p) != null) != properties.Length)
{
// TODO log when index cannot be scaffolding because of missing columns
Logger.LogWarning(RelationalDesignStrings.UnableToScaffoldIndexMissingProperty(index.Name));
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void E2ETest_UseAttributesInsteadOfFluentApi()
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.sql_variantColumn", "sql_variant"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.xmlColumn", "xml"),
RelationalDesignStrings.UnableToScaffoldIndex("IX_UnscaffoldableIndex"),
RelationalDesignStrings.UnableToScaffoldIndexMissingProperty("IX_UnscaffoldableIndex"),
SqlServerDesignStrings.DataTypeDoesNotAllowSqlServerIdentityStrategy("dbo.PropertyConfiguration.PropertyConfigurationID","tinyint"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"),
RelationalDesignStrings.PrimaryKeyErrorPropertyNotFound("dbo.TableWithUnmappablePrimaryKeyColumn"),
Expand Down Expand Up @@ -191,7 +191,7 @@ public void E2ETest_AllFluentApi()
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.sql_variantColumn", "sql_variant"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.xmlColumn", "xml"),
RelationalDesignStrings.UnableToScaffoldIndex("IX_UnscaffoldableIndex"),
RelationalDesignStrings.UnableToScaffoldIndexMissingProperty("IX_UnscaffoldableIndex"),
SqlServerDesignStrings.DataTypeDoesNotAllowSqlServerIdentityStrategy("dbo.PropertyConfiguration.PropertyConfigurationID","tinyint"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"),
RelationalDesignStrings.PrimaryKeyErrorPropertyNotFound("dbo.TableWithUnmappablePrimaryKeyColumn"),
Expand Down

0 comments on commit 503095e

Please sign in to comment.