Skip to content

Commit

Permalink
Be consistent about OnModelCreating as the terminology for fluent API
Browse files Browse the repository at this point in the history
Use "navigation" rather than "navigation property"
Check usage of {foreignKey} and for correct quoting and use foreignKeyProperties where appropriate
Fix AnnotationNotFound, BadFilterDerivedType, CircularDependency
Update DisplayName for shared-type entity types to include the entity type name

Part of #7201
Fixes #22310
  • Loading branch information
AndriySvyryd committed Sep 1, 2020
1 parent e0f9cee commit 6bcc088
Show file tree
Hide file tree
Showing 27 changed files with 463 additions and 431 deletions.
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs

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

2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Properties/CosmosStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
<value>There is no string-based representation of this query as it's executed using 'ReadItemQueryAsync({resourceId}, {partitionKey})'.</value>
</data>
<data name="NullTypeMappingInSqlTree" xml:space="preserve">
<value>Null TypeMapping in Sql Tree.</value>
<value>Null TypeMapping in SQL tree.</value>
</data>
<data name="OffsetRequiresLimit" xml:space="preserve">
<value>Offset is not supported without Limit.</value>
Expand Down
8 changes: 4 additions & 4 deletions src/EFCore.Design/Properties/DesignStrings.Designer.cs

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

2 changes: 1 addition & 1 deletion src/EFCore.Design/Properties/DesignStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<value>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.</value>
</data>
<data name="ForeignKeyScaffoldErrorPrincipalTableScaffoldingError" xml:space="preserve">
<value>Could not scaffold the foreign key '{foreignKeyName}'. The referenced table '{principaltableName}' could not be scaffolded.</value>
<value>Could not scaffold the foreign key '{foreignKeyName}'. The referenced table '{principalTableName}' could not be scaffolded.</value>
</data>
<data name="ForeignKeyScaffoldErrorPropertyNotFound" xml:space="preserve">
<value>Could not scaffold the foreign key '{foreignKeyName}'. The following columns in the foreign key could not be scaffolded: {columnNames}.</value>
Expand Down
6 changes: 2 additions & 4 deletions src/EFCore.Relational/Extensions/Internal/TupleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static class TupleExtensions
/// </summary>
public static string FormatTables([NotNull] this IEnumerable<(string Table, string Schema)> tables)
=> "{"
+ string.Join(", ", tables.Select(FormatTable))
+ string.Join(", ", tables.Select(t => "'" + FormatTable(t) + "'"))
+ "}";

/// <summary>
Expand All @@ -34,8 +34,6 @@ public static string FormatTables([NotNull] this IEnumerable<(string Table, stri
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public static string FormatTable(this (string Table, string Schema) table)
=> "'"
+ (table.Schema == null ? table.Table : table.Schema + "." + table.Table)
+ "'";
=> table.Schema == null ? table.Table : table.Schema + "." + table.Table;
}
}
58 changes: 29 additions & 29 deletions src/EFCore.Relational/Properties/RelationalStrings.Designer.cs

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions src/EFCore.Relational/Properties/RelationalStrings.resx

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/EFCore.Relational/Update/ColumnModification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public virtual void AddSharedColumnModification([NotNull] ColumnModification mod
Entry.BuildCurrentValuesString(Entry.EntityType.FindPrimaryKey().Properties),
Entry.BuildCurrentValuesString(new[] { Property }),
modification.Entry.BuildCurrentValuesString(new[] { modification.Property }),
"{'" + ColumnName + "'}"));
ColumnName));
}

throw new InvalidOperationException(
Expand All @@ -393,7 +393,7 @@ public virtual void AddSharedColumnModification([NotNull] ColumnModification mod
modification.Entry.EntityType.DisplayName(),
new[] { Property }.Format(),
new[] { modification.Property }.Format(),
"{'" + ColumnName + "'}"));
ColumnName));
}

if (UseOriginalValueParameter
Expand All @@ -416,7 +416,7 @@ public virtual void AddSharedColumnModification([NotNull] ColumnModification mod
Entry.BuildCurrentValuesString(Entry.EntityType.FindPrimaryKey().Properties),
Entry.BuildOriginalValuesString(new[] { Property }),
modification.Entry.BuildOriginalValuesString(new[] { modification.Property }),
"{'" + ColumnName + "'}"));
ColumnName));
}

throw new InvalidOperationException(
Expand All @@ -425,7 +425,7 @@ public virtual void AddSharedColumnModification([NotNull] ColumnModification mod
modification.Entry.EntityType.DisplayName(),
new[] { Property }.Format(),
new[] { modification.Property }.Format(),
"{'" + ColumnName + "'}"));
ColumnName));
}
}

Expand Down
24 changes: 18 additions & 6 deletions src/EFCore.Relational/Update/Internal/CommandBatchPreparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ private string FormatCycle(IReadOnlyList<Tuple<ModificationCommand, Modification
}
}

if (!_sensitiveLoggingEnabled)
{
builder.Append(CoreStrings.SensitiveDataDisabled);
}

return builder.ToString();
}

Expand Down Expand Up @@ -359,10 +364,13 @@ private void Format(IForeignKey foreignKey, ModificationCommand source, Modifica
var reverseDependency = !source.Entries.Any(e => foreignKey.DeclaringEntityType.IsAssignableFrom(e.EntityType));
if (reverseDependency)
{
builder.Append(" <-");
builder.AppendLine(" <-");
}
else
{
builder.Append(" ");
}

builder.Append(" ");
if (foreignKey.DependentToPrincipal != null
|| foreignKey.PrincipalToDependent != null)
{
Expand Down Expand Up @@ -416,7 +424,7 @@ private void Format(IForeignKey foreignKey, ModificationCommand source, Modifica

if (!reverseDependency)
{
builder.Append("<- ");
builder.AppendLine("<-");
}
}

Expand All @@ -425,10 +433,14 @@ private void Format(IIndex index, ModificationCommand source, ModificationComman
var reverseDependency = source.EntityState != EntityState.Deleted;
if (reverseDependency)
{
builder.Append(" <-");
builder.AppendLine(" <-");
}
else
{
builder.Append(" ");
}

builder.Append(" Index ");
builder.Append("Index ");

var dependentCommand = reverseDependency ? target : source;
var dependentEntry = dependentCommand.Entries.First(e => index.DeclaringEntityType.IsAssignableFrom(e.EntityType));
Expand All @@ -455,7 +467,7 @@ private void Format(IIndex index, ModificationCommand source, ModificationComman

if (!reverseDependency)
{
builder.Append("<- ");
builder.AppendLine("<-");
}
}

Expand Down
16 changes: 8 additions & 8 deletions src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs

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

Loading

0 comments on commit 6bcc088

Please sign in to comment.