diff --git a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
index 5e4c9e83e96..d7271eed8f4 100644
--- a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
+++ b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs
@@ -20,6 +20,12 @@ namespace Microsoft.EntityFrameworkCore
///
public static class RelationalEntityTypeExtensions
{
+ ///
+ /// Gets the name used for the mapped using
+ /// .
+ ///
+ public static readonly string DefaultQueryNameBase = "MappedSqlQuery";
+
///
/// Returns the name of the table to which the entity type is mapped
/// or if not mapped to a table.
@@ -432,7 +438,7 @@ public static IEnumerable GetViewMappings([NotNull] this IEntityTy
/// The entity type.
/// Gets the default SQL query name.
public static string GetDefaultSqlQueryName([NotNull] this IReadOnlyEntityType entityType)
- => entityType.Name + "." + SqlQueryExtensions.DefaultQueryNameBase;
+ => entityType.Name + "." + DefaultQueryNameBase;
///
/// Returns the SQL string used to provide data for the entity type or if not mapped to a SQL string.
diff --git a/src/EFCore.Relational/Extensions/RelationalModelExtensions.cs b/src/EFCore.Relational/Extensions/RelationalModelExtensions.cs
index fe1f413bfc0..008ba1d30b7 100644
--- a/src/EFCore.Relational/Extensions/RelationalModelExtensions.cs
+++ b/src/EFCore.Relational/Extensions/RelationalModelExtensions.cs
@@ -4,10 +4,8 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
@@ -22,67 +20,6 @@ namespace Microsoft.EntityFrameworkCore
///
public static class RelationalModelExtensions
{
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IRelationalModel model,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString).Append("RelationalModel: ");
-
- if (model.Collation != null)
- {
- builder.AppendLine().Append(indentString).Append("Collation: " + model.Collation);
- }
-
- foreach (var table in model.Tables)
- {
- builder.AppendLine().Append(table.ToDebugString(options, indent + 2));
- }
-
- foreach (var view in model.Views)
- {
- builder.AppendLine().Append(view.ToDebugString(options, indent + 2));
- }
-
- foreach (var function in model.Functions)
- {
- builder.AppendLine().Append(function.ToDebugString(options, indent + 2));
- }
-
- foreach (var query in model.Queries)
- {
- builder.AppendLine().Append(query.ToDebugString(options, indent + 2));
- }
-
- foreach (var sequence in model.Sequences)
- {
- builder.AppendLine().Append(sequence.ToDebugString(options, indent + 2));
- }
-
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(model.AnnotationsToDebugString(indent));
- }
-
- return builder.ToString();
- }
-
///
/// Returns the default schema to use for the model, or if none has been set.
///
diff --git a/src/EFCore.Relational/Metadata/CheckConstraintExtensions.cs b/src/EFCore.Relational/Metadata/CheckConstraintExtensions.cs
deleted file mode 100644
index 785ec902d1e..00000000000
--- a/src/EFCore.Relational/Metadata/CheckConstraintExtensions.cs
+++ /dev/null
@@ -1,58 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class CheckConstraintExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ICheckConstraint constraint,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("Check: ");
-
- builder.Append(constraint.Name)
- .Append(" \"")
- .Append(constraint.Sql)
- .Append("\"");
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(constraint.AnnotationsToDebugString(indent: indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ColumnExtensions.cs b/src/EFCore.Relational/Metadata/ColumnExtensions.cs
deleted file mode 100644
index 15e18e48b56..00000000000
--- a/src/EFCore.Relational/Metadata/ColumnExtensions.cs
+++ /dev/null
@@ -1,69 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class ColumnExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IColumn column,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append($"Column: {column.Table.Name}.");
- }
-
- builder.Append(column.Name).Append(" (");
-
- builder.Append(column.StoreType).Append(")");
-
- if (column.IsNullable)
- {
- builder.Append(" Nullable");
- }
- else
- {
- builder.Append(" NonNullable");
- }
-
- builder.Append(")");
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(column.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ColumnMappingExtensions.cs b/src/EFCore.Relational/Metadata/ColumnMappingExtensions.cs
deleted file mode 100644
index e120d606211..00000000000
--- a/src/EFCore.Relational/Metadata/ColumnMappingExtensions.cs
+++ /dev/null
@@ -1,65 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class ColumnMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IColumnMapping columnMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("ColumnMapping: ");
- }
-
- builder
- .Append(columnMapping.Property.DeclaringEntityType.DisplayName())
- .Append(".")
- .Append(columnMapping.Property.Name)
- .Append(" - ");
-
- builder
- .Append(columnMapping.Column.Table.Name)
- .Append(".")
- .Append(columnMapping.Column.Name);
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(columnMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/DbFunctionExtensions.cs b/src/EFCore.Relational/Metadata/DbFunctionExtensions.cs
deleted file mode 100644
index 7b2c85b1fb2..00000000000
--- a/src/EFCore.Relational/Metadata/DbFunctionExtensions.cs
+++ /dev/null
@@ -1,76 +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.Linq;
-using System.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class DbFunctionExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IReadOnlyDbFunction function,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("DbFunction: ");
-
- builder.Append(function.ReturnType.ShortDisplayName())
- .Append(" ");
-
- if (function.Schema != null)
- {
- builder
- .Append(function.Schema)
- .Append(".");
- }
-
- builder.Append(function.Name);
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- var parameters = function.Parameters.ToList();
- if (parameters.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Parameters: ");
- foreach (var parameter in parameters)
- {
- builder.AppendLine().Append(parameter.ToDebugString(options, indent + 4));
- }
- }
-
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(function.AnnotationsToDebugString(indent: indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/DbFunctionParameterExtensions.cs b/src/EFCore.Relational/Metadata/DbFunctionParameterExtensions.cs
deleted file mode 100644
index 43d77e6c403..00000000000
--- a/src/EFCore.Relational/Metadata/DbFunctionParameterExtensions.cs
+++ /dev/null
@@ -1,57 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class DbFunctionParameterExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IReadOnlyDbFunctionParameter parameter,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("DbFunctionParameter: ");
-
- builder.Append(parameter.Name)
- .Append(" ")
- .Append(parameter.StoreType);
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(parameter.AnnotationsToDebugString(indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ForeignKeyConstraintExtensions.cs b/src/EFCore.Relational/Metadata/ForeignKeyConstraintExtensions.cs
deleted file mode 100644
index a082864fdbe..00000000000
--- a/src/EFCore.Relational/Metadata/ForeignKeyConstraintExtensions.cs
+++ /dev/null
@@ -1,73 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata.Internal;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class ForeignKeyConstraintExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IForeignKeyConstraint foreignKey,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("ForeignKey: ");
- }
-
- builder
- .Append(foreignKey.Name)
- .Append(" ")
- .Append(foreignKey.Table.Name)
- .Append(" ")
- .Append(ColumnBase.Format(foreignKey.Columns))
- .Append(" -> ")
- .Append(foreignKey.PrincipalTable.Name)
- .Append(" ")
- .Append(ColumnBase.Format(foreignKey.PrincipalColumns));
-
- if (foreignKey.OnDeleteAction != ReferentialAction.NoAction)
- {
- builder
- .Append(" ")
- .Append(foreignKey.OnDeleteAction);
- }
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(foreignKey.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/FunctionColumnExtensions.cs b/src/EFCore.Relational/Metadata/FunctionColumnExtensions.cs
deleted file mode 100644
index 81414d4f50d..00000000000
--- a/src/EFCore.Relational/Metadata/FunctionColumnExtensions.cs
+++ /dev/null
@@ -1,69 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class FunctionColumnExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IFunctionColumn column,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append($"FunctionColumn: {column.Table.Name}.");
- }
-
- builder.Append(column.Name).Append(" (");
-
- builder.Append(column.StoreType).Append(")");
-
- if (column.IsNullable)
- {
- builder.Append(" Nullable");
- }
- else
- {
- builder.Append(" NonNullable");
- }
-
- builder.Append(")");
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(column.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/FunctionColumnMappingExtensions.cs b/src/EFCore.Relational/Metadata/FunctionColumnMappingExtensions.cs
deleted file mode 100644
index d2212aa5bac..00000000000
--- a/src/EFCore.Relational/Metadata/FunctionColumnMappingExtensions.cs
+++ /dev/null
@@ -1,58 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class FunctionColumnMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IFunctionColumnMapping columnMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("FunctionColumnMapping: ");
- }
-
- builder.Append(columnMapping.Property.Name).Append(" - ");
-
- builder.Append(columnMapping.Column.Name);
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(columnMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/FunctionMappingExtensions.cs b/src/EFCore.Relational/Metadata/FunctionMappingExtensions.cs
deleted file mode 100644
index 0b5e077c046..00000000000
--- a/src/EFCore.Relational/Metadata/FunctionMappingExtensions.cs
+++ /dev/null
@@ -1,68 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class FunctionMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IFunctionMapping functionMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("FunctionMapping: ");
- }
-
- builder.Append(functionMapping.EntityType.Name).Append(" - ");
-
- builder.Append(functionMapping.Table.Name);
-
- if (functionMapping.IsDefaultFunctionMapping)
- {
- builder.Append(" DefaultMapping");
- }
-
- if (functionMapping.IncludesDerivedTypes)
- {
- builder.Append(" IncludesDerivedTypes");
- }
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(functionMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ICheckConstraint.cs b/src/EFCore.Relational/Metadata/ICheckConstraint.cs
index 9551015debd..f224038f4b4 100644
--- a/src/EFCore.Relational/Metadata/ICheckConstraint.cs
+++ b/src/EFCore.Relational/Metadata/ICheckConstraint.cs
@@ -1,6 +1,7 @@
// 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.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -16,5 +17,42 @@ public interface ICheckConstraint : IReadOnlyCheckConstraint, IAnnotatable
/// Gets the in which this check constraint is defined.
///
new IEntityType EntityType { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("Check: ");
+
+ builder.Append(Name)
+ .Append(" \"")
+ .Append(Sql)
+ .Append("\"");
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent: indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IColumn.cs b/src/EFCore.Relational/Metadata/IColumn.cs
index e9c5a9ded7a..084af6be25e 100644
--- a/src/EFCore.Relational/Metadata/IColumn.cs
+++ b/src/EFCore.Relational/Metadata/IColumn.cs
@@ -3,6 +3,8 @@
using System.Collections.Generic;
using System.Linq;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -116,5 +118,53 @@ public virtual string? Comment
public virtual string? Collation
=> PropertyMappings.First().Property
.GetCollation(StoreObjectIdentifier.Table(Table.Name, Table.Schema));
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append($"Column: {Table.Name}.");
+ }
+
+ builder.Append(Name).Append(" (");
+
+ builder.Append(StoreType).Append(")");
+
+ if (IsNullable)
+ {
+ builder.Append(" Nullable");
+ }
+ else
+ {
+ builder.Append(" NonNullable");
+ }
+
+ builder.Append(")");
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IColumnMapping.cs b/src/EFCore.Relational/Metadata/IColumnMapping.cs
index f8a08348061..a76ac969330 100644
--- a/src/EFCore.Relational/Metadata/IColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/IColumnMapping.cs
@@ -1,6 +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.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+
#nullable enable
namespace Microsoft.EntityFrameworkCore.Metadata
@@ -19,5 +22,49 @@ public interface IColumnMapping : IColumnMappingBase
/// Gets the containing table mapping.
///
new ITableMapping TableMapping { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("ColumnMapping: ");
+ }
+
+ builder
+ .Append(Property.DeclaringEntityType.DisplayName())
+ .Append(".")
+ .Append(Property.Name)
+ .Append(" - ");
+
+ builder
+ .Append(Column.Table.Name)
+ .Append(".")
+ .Append(Column.Name);
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IForeignKeyConstraint.cs b/src/EFCore.Relational/Metadata/IForeignKeyConstraint.cs
index 0895dc59863..9cf8ed2d9b2 100644
--- a/src/EFCore.Relational/Metadata/IForeignKeyConstraint.cs
+++ b/src/EFCore.Relational/Metadata/IForeignKeyConstraint.cs
@@ -2,7 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable enable
@@ -48,5 +50,55 @@ public interface IForeignKeyConstraint : IAnnotatable
/// Gets the action to be performed when the referenced row is deleted.
///
ReferentialAction OnDeleteAction { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("ForeignKey: ");
+ }
+
+ builder
+ .Append(Name)
+ .Append(" ")
+ .Append(Table.Name)
+ .Append(" ")
+ .Append(ColumnBase.Format(Columns))
+ .Append(" -> ")
+ .Append(PrincipalTable.Name)
+ .Append(" ")
+ .Append(ColumnBase.Format(PrincipalColumns));
+
+ if (OnDeleteAction != ReferentialAction.NoAction)
+ {
+ builder
+ .Append(" ")
+ .Append(OnDeleteAction);
+ }
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IFunctionColumn.cs b/src/EFCore.Relational/Metadata/IFunctionColumn.cs
index 4ef13a823a6..7de57625e1f 100644
--- a/src/EFCore.Relational/Metadata/IFunctionColumn.cs
+++ b/src/EFCore.Relational/Metadata/IFunctionColumn.cs
@@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -21,5 +23,53 @@ public interface IFunctionColumn : IColumnBase
/// Gets the property mappings.
///
new IEnumerable PropertyMappings { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append($"FunctionColumn: {Table.Name}.");
+ }
+
+ builder.Append(Name).Append(" (");
+
+ builder.Append(StoreType).Append(")");
+
+ if (IsNullable)
+ {
+ builder.Append(" Nullable");
+ }
+ else
+ {
+ builder.Append(" NonNullable");
+ }
+
+ builder.Append(")");
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IFunctionColumnMapping.cs b/src/EFCore.Relational/Metadata/IFunctionColumnMapping.cs
index 9c6d7c66a5a..c5c367189f1 100644
--- a/src/EFCore.Relational/Metadata/IFunctionColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/IFunctionColumnMapping.cs
@@ -3,6 +3,9 @@
#nullable enable
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+
namespace Microsoft.EntityFrameworkCore.Metadata
{
///
@@ -19,5 +22,42 @@ public interface IFunctionColumnMapping : IColumnMappingBase
/// Gets the containing function mapping.
///
IFunctionMapping FunctionMapping { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("FunctionColumnMapping: ");
+ }
+
+ builder.Append(Property.Name).Append(" - ");
+
+ builder.Append(Column.Name);
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IFunctionMapping.cs b/src/EFCore.Relational/Metadata/IFunctionMapping.cs
index 8e4531ef0a3..bd22056d913 100644
--- a/src/EFCore.Relational/Metadata/IFunctionMapping.cs
+++ b/src/EFCore.Relational/Metadata/IFunctionMapping.cs
@@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -32,5 +34,52 @@ public interface IFunctionMapping : ITableMappingBase
/// Gets the properties mapped to columns on the target function.
///
new IEnumerable ColumnMappings { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("FunctionMapping: ");
+ }
+
+ builder.Append(EntityType.Name).Append(" - ");
+
+ builder.Append(Table.Name);
+
+ if (IsDefaultFunctionMapping)
+ {
+ builder.Append(" DefaultMapping");
+ }
+
+ if (IncludesDerivedTypes)
+ {
+ builder.Append(" IncludesDerivedTypes");
+ }
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IReadOnlyDbFunction.cs b/src/EFCore.Relational/Metadata/IReadOnlyDbFunction.cs
index d1447c8a85d..2b49e37435a 100644
--- a/src/EFCore.Relational/Metadata/IReadOnlyDbFunction.cs
+++ b/src/EFCore.Relational/Metadata/IReadOnlyDbFunction.cs
@@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Reflection;
+using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
using Microsoft.EntityFrameworkCore.Storage;
@@ -88,5 +90,59 @@ public interface IReadOnlyDbFunction : IReadOnlyAnnotatable
/// Gets the translation callback for performing custom translation of the method call into a SQL expression fragment.
///
Func, SqlExpression>? Translation { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("DbFunction: ");
+
+ builder.Append(ReturnType.ShortDisplayName())
+ .Append(" ");
+
+ if (Schema != null)
+ {
+ builder
+ .Append(Schema)
+ .Append(".");
+ }
+
+ builder.Append(Name);
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ var parameters = Parameters.ToList();
+ if (parameters.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Parameters: ");
+ foreach (var parameter in parameters)
+ {
+ builder.AppendLine().Append(parameter.ToDebugString(options, indent + 4));
+ }
+ }
+
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent: indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IReadOnlyDbFunctionParameter.cs b/src/EFCore.Relational/Metadata/IReadOnlyDbFunctionParameter.cs
index 7e9690240ef..c177cda59f1 100644
--- a/src/EFCore.Relational/Metadata/IReadOnlyDbFunctionParameter.cs
+++ b/src/EFCore.Relational/Metadata/IReadOnlyDbFunctionParameter.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage;
@@ -44,5 +45,41 @@ public interface IReadOnlyDbFunctionParameter : IReadOnlyAnnotatable
/// Gets the for this parameter.
///
RelationalTypeMapping? TypeMapping { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("DbFunctionParameter: ");
+
+ builder.Append(Name)
+ .Append(" ")
+ .Append(StoreType);
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IReadOnlySequence.cs b/src/EFCore.Relational/Metadata/IReadOnlySequence.cs
index 64bc60c9af2..a2380b4239c 100644
--- a/src/EFCore.Relational/Metadata/IReadOnlySequence.cs
+++ b/src/EFCore.Relational/Metadata/IReadOnlySequence.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -64,5 +65,75 @@ public interface IReadOnlySequence : IReadOnlyAnnotatable
/// is reached.
///
bool IsCyclic { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("Sequence: ");
+
+ if (Schema != null)
+ {
+ builder
+ .Append(Schema)
+ .Append(".");
+ }
+
+ builder.Append(Name);
+
+ if (!IsCyclic)
+ {
+ builder.Append(" Cyclic");
+ }
+
+ if (StartValue != 1)
+ {
+ builder.Append(" Start: ")
+ .Append(StartValue);
+ }
+
+ if (IncrementBy != 1)
+ {
+ builder.Append(" IncrementBy: ")
+ .Append(IncrementBy);
+ }
+
+ if (MinValue != null)
+ {
+ builder.Append(" Min: ")
+ .Append(MinValue);
+ }
+
+ if (MaxValue != null)
+ {
+ builder.Append(" Max: ")
+ .Append(MaxValue);
+ }
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent: indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IRelationalModel.cs b/src/EFCore.Relational/Metadata/IRelationalModel.cs
index 714536baefe..db3bf4a8bde 100644
--- a/src/EFCore.Relational/Metadata/IRelationalModel.cs
+++ b/src/EFCore.Relational/Metadata/IRelationalModel.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
@@ -96,5 +97,62 @@ IEnumerable Sequences
/// A list of parameter types.
/// The or if no function with the given name was defined.
IStoreFunction? FindFunction([NotNull] string name, [CanBeNull] string? schema, [NotNull] IReadOnlyList parameters);
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString).Append("RelationalModel: ");
+
+ if (Collation != null)
+ {
+ builder.AppendLine().Append(indentString).Append("Collation: " + Collation);
+ }
+
+ foreach (var table in Tables)
+ {
+ builder.AppendLine().Append(table.ToDebugString(options, indent + 2));
+ }
+
+ foreach (var view in Views)
+ {
+ builder.AppendLine().Append(view.ToDebugString(options, indent + 2));
+ }
+
+ foreach (var function in Functions)
+ {
+ builder.AppendLine().Append(function.ToDebugString(options, indent + 2));
+ }
+
+ foreach (var query in Queries)
+ {
+ builder.AppendLine().Append(query.ToDebugString(options, indent + 2));
+ }
+
+ foreach (var sequence in Sequences)
+ {
+ builder.AppendLine().Append(sequence.ToDebugString(options, indent + 2));
+ }
+
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/ISqlQuery.cs b/src/EFCore.Relational/Metadata/ISqlQuery.cs
index 1f4edc95c20..7012abc07fb 100644
--- a/src/EFCore.Relational/Metadata/ISqlQuery.cs
+++ b/src/EFCore.Relational/Metadata/ISqlQuery.cs
@@ -2,7 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Linq;
+using System.Text;
using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -37,5 +40,72 @@ public interface ISqlQuery : ITableBase
/// Gets the SQL query string.
///
public string Sql { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("SqlQuery: ");
+
+ if (Schema != null)
+ {
+ builder
+ .Append(Schema)
+ .Append(".");
+ }
+
+ builder.Append(Name);
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ if (Sql != null)
+ {
+ builder.AppendLine().Append(indentString).Append(" Sql: ");
+ builder.AppendLine().Append(indentString).Append(new string(' ', 4)).Append(Sql);
+ }
+
+ var mappings = EntityTypeMappings.ToList();
+ if (mappings.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
+ foreach (var mapping in mappings)
+ {
+ builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var columns = Columns.ToList();
+ if (columns.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Columns: ");
+ foreach (var column in columns)
+ {
+ builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
+ }
+ }
+
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/ISqlQueryColumn.cs b/src/EFCore.Relational/Metadata/ISqlQueryColumn.cs
index a7e447b5006..61e2d21fd97 100644
--- a/src/EFCore.Relational/Metadata/ISqlQueryColumn.cs
+++ b/src/EFCore.Relational/Metadata/ISqlQueryColumn.cs
@@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -21,5 +23,53 @@ public interface ISqlQueryColumn : IColumnBase
/// Gets the property mappings.
///
new IEnumerable PropertyMappings { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append($"SqlQueryColumn: {Table.Name}.");
+ }
+
+ builder.Append(Name).Append(" (");
+
+ builder.Append(StoreType).Append(")");
+
+ if (IsNullable)
+ {
+ builder.Append(" Nullable");
+ }
+ else
+ {
+ builder.Append(" NonNullable");
+ }
+
+ builder.Append(")");
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/ISqlQueryColumnMapping.cs b/src/EFCore.Relational/Metadata/ISqlQueryColumnMapping.cs
index 041156f854b..2ef7268d131 100644
--- a/src/EFCore.Relational/Metadata/ISqlQueryColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/ISqlQueryColumnMapping.cs
@@ -3,6 +3,9 @@
#nullable enable
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+
namespace Microsoft.EntityFrameworkCore.Metadata
{
///
@@ -19,5 +22,42 @@ public interface ISqlQueryColumnMapping : IColumnMappingBase
/// Gets the containing SQL query mapping.
///
ISqlQueryMapping SqlQueryMapping { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("SqlQueryColumnMapping: ");
+ }
+
+ builder.Append(Property.Name).Append(" - ");
+
+ builder.Append(Column.Name);
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/ISqlQueryMapping.cs b/src/EFCore.Relational/Metadata/ISqlQueryMapping.cs
index 7382420136c..229e9a761a4 100644
--- a/src/EFCore.Relational/Metadata/ISqlQueryMapping.cs
+++ b/src/EFCore.Relational/Metadata/ISqlQueryMapping.cs
@@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -27,5 +29,47 @@ public interface ISqlQueryMapping : ITableMappingBase
/// Gets the properties mapped to columns on the target SQL query.
///
new IEnumerable ColumnMappings { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("SqlQueryMapping: ");
+ }
+
+ builder.Append(EntityType.Name).Append(" - ");
+
+ builder.Append(Table.Name);
+
+ if (IncludesDerivedTypes)
+ {
+ builder.Append(" IncludesDerivedTypes");
+ }
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IStoreFunction.cs b/src/EFCore.Relational/Metadata/IStoreFunction.cs
index c8a543b70ce..ee6fe292944 100644
--- a/src/EFCore.Relational/Metadata/IStoreFunction.cs
+++ b/src/EFCore.Relational/Metadata/IStoreFunction.cs
@@ -2,7 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Linq;
+using System.Text;
using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -53,5 +56,92 @@ public interface IStoreFunction : ITableBase
/// Gets the column mapped to the given property. Returns if no column is mapped to the given property.
///
new IFunctionColumn? FindColumn([NotNull] IProperty property);
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("StoreFunction: ");
+
+ if (ReturnType != null)
+ {
+ builder.Append(ReturnType);
+ }
+ else
+ {
+ builder.Append(EntityTypeMappings.FirstOrDefault()?.EntityType.DisplayName() ?? "");
+ }
+
+ builder.Append(" ");
+
+ if (Schema != null)
+ {
+ builder
+ .Append(Schema)
+ .Append(".");
+ }
+
+ builder.Append(Name);
+
+ if (IsBuiltIn)
+ {
+ builder.Append(" IsBuiltIn");
+ }
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ var parameters = Parameters.ToList();
+ if (parameters.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Parameters: ");
+ foreach (var parameter in parameters)
+ {
+ builder.AppendLine().Append(parameter.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var mappings = EntityTypeMappings.ToList();
+ if (mappings.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
+ foreach (var mapping in mappings)
+ {
+ builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var columns = Columns.ToList();
+ if (columns.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Columns: ");
+ foreach (var column in columns)
+ {
+ builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
+ }
+ }
+
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent: indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs b/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs
index 514dfa10b18..7597e8fa6e0 100644
--- a/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs
+++ b/src/EFCore.Relational/Metadata/IStoreFunctionParameter.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -32,5 +33,41 @@ public interface IStoreFunctionParameter : IAnnotatable
/// Gets the store type of this parameter.
///
string Type { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("StoreFunctionParameter: ");
+
+ builder.Append(Name)
+ .Append(" ")
+ .Append(Type);
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/ITable.cs b/src/EFCore.Relational/Metadata/ITable.cs
index d17329d5b82..fdb42f8861d 100644
--- a/src/EFCore.Relational/Metadata/ITable.cs
+++ b/src/EFCore.Relational/Metadata/ITable.cs
@@ -3,7 +3,9 @@
using System.Collections.Generic;
using System.Linq;
+using System.Text;
using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
@@ -73,5 +75,135 @@ public virtual string? Comment
/// Gets the column mapped to the given property. Returns if no column is mapped to the given property.
///
new IColumn? FindColumn([NotNull] IProperty property);
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("Table: ");
+
+ if (Schema != null)
+ {
+ builder
+ .Append(Schema)
+ .Append(".");
+ }
+
+ builder.Append(Name);
+
+ if (IsExcludedFromMigrations)
+ {
+ builder.Append(" ExcludedFromMigrations");
+ }
+
+ if (PrimaryKey == null)
+ {
+ builder.Append(" Keyless");
+ }
+ else
+ {
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ builder.AppendLine();
+ }
+
+ builder.Append(PrimaryKey.ToDebugString(options, indent + 2));
+ }
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0 && Comment != null)
+ {
+ builder
+ .AppendLine()
+ .Append(indentString)
+ .AppendLine(" Comment:")
+ .Append(indentString)
+ .Append(Comment);
+ }
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ var mappings = EntityTypeMappings.ToList();
+ if (mappings.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
+ foreach (var mapping in mappings)
+ {
+ builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var columns = Columns.ToList();
+ if (columns.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Columns: ");
+ foreach (var column in columns)
+ {
+ builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var foreignKeyConstraints = ForeignKeyConstraints.ToList();
+ if (foreignKeyConstraints.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" ForeignKeyConstraints: ");
+ foreach (var foreignKeyConstraint in foreignKeyConstraints)
+ {
+ builder.AppendLine().Append(foreignKeyConstraint.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var indexes = Indexes.ToList();
+ if (indexes.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Indexes: ");
+ foreach (var index in indexes)
+ {
+ builder.AppendLine().Append(index.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var uniqueConstraints = UniqueConstraints.Where(uc => !uc.GetIsPrimaryKey()).ToList();
+ if (uniqueConstraints.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" UniqueConstraints: ");
+ foreach (var uniqueConstraint in uniqueConstraints)
+ {
+ builder.AppendLine().Append(uniqueConstraint.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var checkConstraints = CheckConstraints.ToList();
+ if (checkConstraints.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Check constraints: ");
+ foreach (var checkConstraint in checkConstraints)
+ {
+ builder.AppendLine().Append(checkConstraint.ToDebugString(options, indent + 4));
+ }
+ }
+
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/ITableIndex.cs b/src/EFCore.Relational/Metadata/ITableIndex.cs
index 1e0dfe339a3..f0bdce32b2c 100644
--- a/src/EFCore.Relational/Metadata/ITableIndex.cs
+++ b/src/EFCore.Relational/Metadata/ITableIndex.cs
@@ -2,7 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
#nullable enable
@@ -42,5 +44,54 @@ public interface ITableIndex : IAnnotatable
/// Gets the expression used as the index filter.
///
string? Filter { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("Index: ");
+ }
+
+ builder
+ .Append(Name)
+ .Append(" ")
+ .Append(ColumnBase.Format(Columns));
+
+ if (IsUnique)
+ {
+ builder
+ .Append(" Unique");
+ }
+
+ if (!string.IsNullOrWhiteSpace(Filter))
+ {
+ builder
+ .Append(" Filtered");
+ }
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/ITableMapping.cs b/src/EFCore.Relational/Metadata/ITableMapping.cs
index d70d514894a..cceebaf2493 100644
--- a/src/EFCore.Relational/Metadata/ITableMapping.cs
+++ b/src/EFCore.Relational/Metadata/ITableMapping.cs
@@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -21,5 +23,47 @@ public interface ITableMapping : ITableMappingBase
/// Gets the properties mapped to columns on the target table.
///
new IEnumerable ColumnMappings { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("TableMapping: ");
+ }
+
+ builder.Append(EntityType.Name).Append(" - ");
+
+ builder.Append(Table.Name);
+
+ if (IncludesDerivedTypes)
+ {
+ builder.Append(" IncludesDerivedTypes");
+ }
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IUniqueConstraint.cs b/src/EFCore.Relational/Metadata/IUniqueConstraint.cs
index 27bbf27b6af..a05ba8d4b5b 100644
--- a/src/EFCore.Relational/Metadata/IUniqueConstraint.cs
+++ b/src/EFCore.Relational/Metadata/IUniqueConstraint.cs
@@ -2,7 +2,9 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata.Internal;
#nullable enable
@@ -32,5 +34,54 @@ public interface IUniqueConstraint : IAnnotatable
/// Gets the columns that are participating in the unique constraint.
///
IReadOnlyList Columns { get; }
+
+ ///
+ /// Gets a value indicating whether this constraint is the primary key.
+ ///
+ /// if the constraint is the primary key
+ bool GetIsPrimaryKey()
+ => Table.PrimaryKey == this;
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("Key: ");
+ }
+
+ builder
+ .Append(Name)
+ .Append(" ")
+ .Append(ColumnBase.Format(Columns));
+
+ if (GetIsPrimaryKey())
+ {
+ builder.Append(" PrimaryKey");
+ }
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IView.cs b/src/EFCore.Relational/Metadata/IView.cs
index a555cd78329..ec1cc910fc3 100644
--- a/src/EFCore.Relational/Metadata/IView.cs
+++ b/src/EFCore.Relational/Metadata/IView.cs
@@ -2,7 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Linq;
+using System.Text;
using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -37,5 +40,72 @@ public interface IView : ITableBase
/// Gets the view definition or if this view is not managed by migrations.
///
public string? ViewDefinitionSql { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder
+ .Append(indentString)
+ .Append("View: ");
+
+ if (Schema != null)
+ {
+ builder
+ .Append(Schema)
+ .Append(".");
+ }
+
+ builder.Append(Name);
+
+ if ((options & MetadataDebugStringOptions.SingleLine) == 0)
+ {
+ if (ViewDefinitionSql != null)
+ {
+ builder.AppendLine().Append(indentString).Append(" DefinitionSql: ");
+ builder.AppendLine().Append(indentString).Append(new string(' ', 4)).Append(ViewDefinitionSql);
+ }
+
+ var mappings = EntityTypeMappings.ToList();
+ if (mappings.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
+ foreach (var mapping in mappings)
+ {
+ builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
+ }
+ }
+
+ var columns = Columns.ToList();
+ if (columns.Count != 0)
+ {
+ builder.AppendLine().Append(indentString).Append(" Columns: ");
+ foreach (var column in columns)
+ {
+ builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
+ }
+ }
+
+ if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IViewColumn.cs b/src/EFCore.Relational/Metadata/IViewColumn.cs
index 3703fec5065..8ec4389e1f7 100644
--- a/src/EFCore.Relational/Metadata/IViewColumn.cs
+++ b/src/EFCore.Relational/Metadata/IViewColumn.cs
@@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -21,5 +23,53 @@ public interface IViewColumn : IColumnBase
/// Gets the property mappings.
///
new IEnumerable PropertyMappings { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append($"ViewColumn: {Table.Name}.");
+ }
+
+ builder.Append(Name).Append(" (");
+
+ builder.Append(StoreType).Append(")");
+
+ if (IsNullable)
+ {
+ builder.Append(" Nullable");
+ }
+ else
+ {
+ builder.Append(" NonNullable");
+ }
+
+ builder.Append(")");
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IViewColumnMapping.cs b/src/EFCore.Relational/Metadata/IViewColumnMapping.cs
index 6c0cc50123e..e8be8b66e34 100644
--- a/src/EFCore.Relational/Metadata/IViewColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/IViewColumnMapping.cs
@@ -1,6 +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.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+
#nullable enable
namespace Microsoft.EntityFrameworkCore.Metadata
@@ -19,5 +22,42 @@ public interface IViewColumnMapping : IColumnMappingBase
/// Gets the containing view mapping.
///
IViewMapping ViewMapping { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("ViewColumnMapping: ");
+ }
+
+ builder.Append(Property.Name).Append(" - ");
+
+ builder.Append(Column.Name);
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/IViewMapping.cs b/src/EFCore.Relational/Metadata/IViewMapping.cs
index 890efe1259d..d33b3e030c4 100644
--- a/src/EFCore.Relational/Metadata/IViewMapping.cs
+++ b/src/EFCore.Relational/Metadata/IViewMapping.cs
@@ -2,6 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using System.Text;
+using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable enable
@@ -21,5 +23,47 @@ public interface IViewMapping : ITableMappingBase
/// Gets the properties mapped to columns on the target view.
///
new IEnumerable ColumnMappings { get; }
+
+ ///
+ ///
+ /// Creates a human-readable representation of the given metadata.
+ ///
+ ///
+ /// Warning: Do not rely on the format of the returned string.
+ /// It is designed for debugging only and may change arbitrarily between releases.
+ ///
+ ///
+ /// Options for generating the string.
+ /// The number of indent spaces to use before each new line.
+ /// A human-readable representation.
+ string ToDebugString(MetadataDebugStringOptions options, int indent = 0)
+ {
+ var builder = new StringBuilder();
+ var indentString = new string(' ', indent);
+
+ builder.Append(indentString);
+
+ var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
+ if (singleLine)
+ {
+ builder.Append("ViewMapping: ");
+ }
+
+ builder.Append(EntityType.Name).Append(" - ");
+
+ builder.Append(Table.Name);
+
+ if (IncludesDerivedTypes)
+ {
+ builder.Append(" IncludesDerivedTypes");
+ }
+
+ if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
+ {
+ builder.Append(AnnotationsToDebugString(indent + 2));
+ }
+
+ return builder.ToString();
+ }
}
}
diff --git a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs
index 47daf600763..678039cad83 100644
--- a/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs
+++ b/src/EFCore.Relational/Metadata/Internal/CheckConstraint.cs
@@ -177,7 +177,7 @@ public virtual void UpdateConfigurationSource(ConfigurationSource configurationS
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ICheckConstraint)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/Column.cs b/src/EFCore.Relational/Metadata/Internal/Column.cs
index e98e8d424d0..9e3d840c4f8 100644
--- a/src/EFCore.Relational/Metadata/Internal/Column.cs
+++ b/src/EFCore.Relational/Metadata/Internal/Column.cs
@@ -46,7 +46,7 @@ public Column([NotNull] string name, [NotNull] string type, [NotNull] Table tabl
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IColumn)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
ITable IColumn.Table
diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnMapping.cs b/src/EFCore.Relational/Metadata/Internal/ColumnMapping.cs
index 2139c909a3b..87318cf034a 100644
--- a/src/EFCore.Relational/Metadata/Internal/ColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ColumnMapping.cs
@@ -48,7 +48,7 @@ public ColumnMapping(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IColumnMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IColumn IColumnMapping.Column
diff --git a/src/EFCore.Relational/Metadata/Internal/DbFunction.cs b/src/EFCore.Relational/Metadata/Internal/DbFunction.cs
index 3131109a6d4..99c76062410 100644
--- a/src/EFCore.Relational/Metadata/Internal/DbFunction.cs
+++ b/src/EFCore.Relational/Metadata/Internal/DbFunction.cs
@@ -658,7 +658,7 @@ public virtual IReadOnlyList Parameters
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IDbFunction)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IConventionDbFunctionBuilder IConventionDbFunction.Builder
diff --git a/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs b/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs
index 929ead1d371..827a4bcba41 100644
--- a/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs
+++ b/src/EFCore.Relational/Metadata/Internal/DbFunctionParameter.cs
@@ -245,7 +245,7 @@ public virtual bool SetPropagatesNullability(bool propagatesNullability, Configu
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IDbFunctionParameter)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IConventionDbFunctionParameterBuilder IConventionDbFunctionParameter.Builder
diff --git a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs
index 0d2259ad6a9..eda1423169d 100644
--- a/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ForeignKeyConstraint.cs
@@ -94,6 +94,15 @@ public ForeignKeyConstraint(
///
public virtual ReferentialAction OnDeleteAction { get; set; }
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public override string ToString()
+ => ((IForeignKeyConstraint)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+
///
IEnumerable IForeignKeyConstraint.MappedForeignKeys
=> MappedForeignKeys;
@@ -113,14 +122,5 @@ IReadOnlyList IForeignKeyConstraint.Columns
///
IReadOnlyList IForeignKeyConstraint.PrincipalColumns
=> PrincipalColumns;
-
- ///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
- ///
- public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
}
}
diff --git a/src/EFCore.Relational/Metadata/Internal/FunctionColumn.cs b/src/EFCore.Relational/Metadata/Internal/FunctionColumn.cs
index 7ca253ce836..d37307419c2 100644
--- a/src/EFCore.Relational/Metadata/Internal/FunctionColumn.cs
+++ b/src/EFCore.Relational/Metadata/Internal/FunctionColumn.cs
@@ -46,7 +46,7 @@ public virtual StoreFunction Function
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IFunctionColumn)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IStoreFunction IFunctionColumn.Function
diff --git a/src/EFCore.Relational/Metadata/Internal/FunctionColumnMapping.cs b/src/EFCore.Relational/Metadata/Internal/FunctionColumnMapping.cs
index d4a1b14c807..9e00bae3b4b 100644
--- a/src/EFCore.Relational/Metadata/Internal/FunctionColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/FunctionColumnMapping.cs
@@ -47,7 +47,7 @@ public virtual IFunctionMapping FunctionMapping
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IFunctionColumnMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
IFunctionColumn IFunctionColumnMapping.Column
{
diff --git a/src/EFCore.Relational/Metadata/Internal/FunctionMapping.cs b/src/EFCore.Relational/Metadata/Internal/FunctionMapping.cs
index eb11d503d3c..22403426449 100644
--- a/src/EFCore.Relational/Metadata/Internal/FunctionMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/FunctionMapping.cs
@@ -52,7 +52,7 @@ public virtual IStoreFunction StoreFunction
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IFunctionMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IEnumerable IFunctionMapping.ColumnMappings
diff --git a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
index 92eceaf2ac3..755de3a230a 100644
--- a/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
+++ b/src/EFCore.Relational/Metadata/Internal/RelationalModel.cs
@@ -1135,8 +1135,17 @@ public static ReferentialAction ToReferentialAction(DeleteBehavior deleteBehavio
///
public virtual DebugView DebugView
=> new(
- () => this.ToDebugString(MetadataDebugStringOptions.ShortDefault),
- () => this.ToDebugString(MetadataDebugStringOptions.LongDefault));
+ () => ((IRelationalModel)this).ToDebugString(MetadataDebugStringOptions.ShortDefault),
+ () => ((IRelationalModel)this).ToDebugString(MetadataDebugStringOptions.LongDefault));
+
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public override string ToString()
+ => ((IRelationalModel)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
IEnumerable IRelationalModel.Tables
{
diff --git a/src/EFCore.Relational/Metadata/Internal/Sequence.cs b/src/EFCore.Relational/Metadata/Internal/Sequence.cs
index 71db8af6fa3..7a58709e238 100644
--- a/src/EFCore.Relational/Metadata/Internal/Sequence.cs
+++ b/src/EFCore.Relational/Metadata/Internal/Sequence.cs
@@ -620,7 +620,7 @@ public virtual bool IsCyclic
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ISequence)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
diff --git a/src/EFCore.Relational/Metadata/Internal/SqlQuery.cs b/src/EFCore.Relational/Metadata/Internal/SqlQuery.cs
index 0f59a509c6c..73a78f21de7 100644
--- a/src/EFCore.Relational/Metadata/Internal/SqlQuery.cs
+++ b/src/EFCore.Relational/Metadata/Internal/SqlQuery.cs
@@ -47,7 +47,7 @@ public SqlQuery([NotNull] string name, [NotNull] RelationalModel model, [NotNull
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ISqlQuery)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IEnumerable ISqlQuery.EntityTypeMappings
diff --git a/src/EFCore.Relational/Metadata/Internal/SqlQueryColumn.cs b/src/EFCore.Relational/Metadata/Internal/SqlQueryColumn.cs
index 37a4838a916..8f05317dde2 100644
--- a/src/EFCore.Relational/Metadata/Internal/SqlQueryColumn.cs
+++ b/src/EFCore.Relational/Metadata/Internal/SqlQueryColumn.cs
@@ -46,7 +46,7 @@ public virtual SqlQuery SqlQuery
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ISqlQueryColumn)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
ISqlQuery ISqlQueryColumn.SqlQuery
diff --git a/src/EFCore.Relational/Metadata/Internal/SqlQueryColumnMapping.cs b/src/EFCore.Relational/Metadata/Internal/SqlQueryColumnMapping.cs
index b75f39e09d1..64752e06786 100644
--- a/src/EFCore.Relational/Metadata/Internal/SqlQueryColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/SqlQueryColumnMapping.cs
@@ -47,7 +47,7 @@ public virtual ISqlQueryMapping SqlQueryMapping
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ISqlQueryColumnMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
ISqlQueryColumn ISqlQueryColumnMapping.Column
diff --git a/src/EFCore.Relational/Metadata/Internal/SqlQueryMapping.cs b/src/EFCore.Relational/Metadata/Internal/SqlQueryMapping.cs
index 3b5513ef6a4..705b2cef116 100644
--- a/src/EFCore.Relational/Metadata/Internal/SqlQueryMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/SqlQueryMapping.cs
@@ -47,7 +47,7 @@ public virtual ISqlQuery SqlQuery
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ISqlQueryMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IEnumerable ISqlQueryMapping.ColumnMappings
diff --git a/src/EFCore.Relational/Metadata/Internal/StoreFunction.cs b/src/EFCore.Relational/Metadata/Internal/StoreFunction.cs
index 78a00827fc3..cbdcdcd1f6f 100644
--- a/src/EFCore.Relational/Metadata/Internal/StoreFunction.cs
+++ b/src/EFCore.Relational/Metadata/Internal/StoreFunction.cs
@@ -76,7 +76,7 @@ public StoreFunction([NotNull] DbFunction dbFunction, [NotNull] RelationalModel
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IStoreFunction)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IEnumerable IStoreFunction.EntityTypeMappings
diff --git a/src/EFCore.Relational/Metadata/Internal/StoreFunctionParameter.cs b/src/EFCore.Relational/Metadata/Internal/StoreFunctionParameter.cs
index 65614b44495..73b8c43bc51 100644
--- a/src/EFCore.Relational/Metadata/Internal/StoreFunctionParameter.cs
+++ b/src/EFCore.Relational/Metadata/Internal/StoreFunctionParameter.cs
@@ -72,7 +72,7 @@ public StoreFunctionParameter(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IStoreFunctionParameter)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IStoreFunction IStoreFunctionParameter.Function
diff --git a/src/EFCore.Relational/Metadata/Internal/Table.cs b/src/EFCore.Relational/Metadata/Internal/Table.cs
index edc34402d57..bfd0ef995f2 100644
--- a/src/EFCore.Relational/Metadata/Internal/Table.cs
+++ b/src/EFCore.Relational/Metadata/Internal/Table.cs
@@ -6,7 +6,6 @@
using System.Linq;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Infrastructure;
-using CA = System.Diagnostics.CodeAnalysis;
#nullable enable
@@ -139,7 +138,7 @@ public virtual UniqueConstraint? PrimaryKey
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ITable)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IEnumerable ITable.EntityTypeMappings
diff --git a/src/EFCore.Relational/Metadata/Internal/TableIndex.cs b/src/EFCore.Relational/Metadata/Internal/TableIndex.cs
index 3162715bc4b..5b40a65e179 100644
--- a/src/EFCore.Relational/Metadata/Internal/TableIndex.cs
+++ b/src/EFCore.Relational/Metadata/Internal/TableIndex.cs
@@ -78,6 +78,15 @@ public TableIndex(
///
public virtual string? Filter { get; }
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public override string ToString()
+ => ((ITableIndex)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+
///
ITable ITableIndex.Table
=> Table;
@@ -89,14 +98,5 @@ IReadOnlyList ITableIndex.Columns
///
IEnumerable ITableIndex.MappedIndexes
=> MappedIndexes;
-
- ///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
- ///
- public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
}
}
diff --git a/src/EFCore.Relational/Metadata/Internal/TableMapping.cs b/src/EFCore.Relational/Metadata/Internal/TableMapping.cs
index c4ac9f99dac..44bb1873b08 100644
--- a/src/EFCore.Relational/Metadata/Internal/TableMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/TableMapping.cs
@@ -44,7 +44,7 @@ public TableMapping(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((ITableMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
ITableBase ITableMappingBase.Table
diff --git a/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs b/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs
index b412b661a41..a170c78264c 100644
--- a/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs
+++ b/src/EFCore.Relational/Metadata/Internal/UniqueConstraint.cs
@@ -68,6 +68,15 @@ public UniqueConstraint(
///
public override bool IsReadOnly => Table.Model.IsReadOnly;
+ ///
+ /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
+ /// the same compatibility standards as public APIs. It may be changed or removed without notice in
+ /// any release. You should only use it directly in your code with extreme caution and knowing that
+ /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ ///
+ public override string ToString()
+ => ((IUniqueConstraint)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+
///
ITable IUniqueConstraint.Table
=> Table;
@@ -79,14 +88,5 @@ IReadOnlyList IUniqueConstraint.Columns
///
IEnumerable IUniqueConstraint.MappedKeys
=> MappedKeys;
-
- ///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
- ///
- public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
}
}
diff --git a/src/EFCore.Relational/Metadata/Internal/View.cs b/src/EFCore.Relational/Metadata/Internal/View.cs
index f25914f55be..5478e1d2215 100644
--- a/src/EFCore.Relational/Metadata/Internal/View.cs
+++ b/src/EFCore.Relational/Metadata/Internal/View.cs
@@ -48,7 +48,7 @@ public virtual string? ViewDefinitionSql
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IView)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IEnumerable IView.EntityTypeMappings
diff --git a/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs b/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs
index 16f09409ac4..9faf6edb6c8 100644
--- a/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs
@@ -46,7 +46,7 @@ public virtual View View
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IViewColumn)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IView IViewColumn.View
diff --git a/src/EFCore.Relational/Metadata/Internal/ViewColumnMapping.cs b/src/EFCore.Relational/Metadata/Internal/ViewColumnMapping.cs
index c3d35a0391d..502ff0b9b0b 100644
--- a/src/EFCore.Relational/Metadata/Internal/ViewColumnMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ViewColumnMapping.cs
@@ -47,7 +47,7 @@ public virtual IViewMapping ViewMapping
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IViewColumnMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IViewColumn IViewColumnMapping.Column
diff --git a/src/EFCore.Relational/Metadata/Internal/ViewMapping.cs b/src/EFCore.Relational/Metadata/Internal/ViewMapping.cs
index 01108c77c4e..8521e505317 100644
--- a/src/EFCore.Relational/Metadata/Internal/ViewMapping.cs
+++ b/src/EFCore.Relational/Metadata/Internal/ViewMapping.cs
@@ -44,7 +44,7 @@ public virtual IView View
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
public override string ToString()
- => this.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
+ => ((IViewMapping)this).ToDebugString(MetadataDebugStringOptions.SingleLineDefault);
///
IEnumerable IViewMapping.ColumnMappings
diff --git a/src/EFCore.Relational/Metadata/SequenceExtensions.cs b/src/EFCore.Relational/Metadata/SequenceExtensions.cs
deleted file mode 100644
index e940a015192..00000000000
--- a/src/EFCore.Relational/Metadata/SequenceExtensions.cs
+++ /dev/null
@@ -1,91 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Sequence extension methods.
- ///
- public static class SequenceExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IReadOnlySequence sequence,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("Sequence: ");
-
- if (sequence.Schema != null)
- {
- builder
- .Append(sequence.Schema)
- .Append(".");
- }
-
- builder.Append(sequence.Name);
-
- if (!sequence.IsCyclic)
- {
- builder.Append(" Cyclic");
- }
-
- if (sequence.StartValue != 1)
- {
- builder.Append(" Start: ")
- .Append(sequence.StartValue);
- }
-
- if (sequence.IncrementBy != 1)
- {
- builder.Append(" IncrementBy: ")
- .Append(sequence.IncrementBy);
- }
-
- if (sequence.MinValue != null)
- {
- builder.Append(" Min: ")
- .Append(sequence.MinValue);
- }
-
- if (sequence.MaxValue != null)
- {
- builder.Append(" Max: ")
- .Append(sequence.MaxValue);
- }
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(sequence.AnnotationsToDebugString(indent: indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/SqlQueryColumnExtensions.cs b/src/EFCore.Relational/Metadata/SqlQueryColumnExtensions.cs
deleted file mode 100644
index 6c13c84e665..00000000000
--- a/src/EFCore.Relational/Metadata/SqlQueryColumnExtensions.cs
+++ /dev/null
@@ -1,69 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class SqlQueryColumnExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ISqlQueryColumn column,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append($"SqlQueryColumn: {column.Table.Name}.");
- }
-
- builder.Append(column.Name).Append(" (");
-
- builder.Append(column.StoreType).Append(")");
-
- if (column.IsNullable)
- {
- builder.Append(" Nullable");
- }
- else
- {
- builder.Append(" NonNullable");
- }
-
- builder.Append(")");
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(column.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/SqlQueryColumnMappingExtensions.cs b/src/EFCore.Relational/Metadata/SqlQueryColumnMappingExtensions.cs
deleted file mode 100644
index 2cd98627b46..00000000000
--- a/src/EFCore.Relational/Metadata/SqlQueryColumnMappingExtensions.cs
+++ /dev/null
@@ -1,58 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class SqlQueryColumnMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ISqlQueryColumnMapping columnMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("SqlQueryColumnMapping: ");
- }
-
- builder.Append(columnMapping.Property.Name).Append(" - ");
-
- builder.Append(columnMapping.Column.Name);
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(columnMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/SqlQueryExtensions.cs b/src/EFCore.Relational/Metadata/SqlQueryExtensions.cs
index 18c558f4518..f7c117a7d64 100644
--- a/src/EFCore.Relational/Metadata/SqlQueryExtensions.cs
+++ b/src/EFCore.Relational/Metadata/SqlQueryExtensions.cs
@@ -1,10 +1,7 @@
// 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.Linq;
-using System.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
+using System;
#nullable enable
@@ -19,77 +16,7 @@ public static class SqlQueryExtensions
/// Gets the name used for the mapped using
/// .
///
- public static readonly string DefaultQueryNameBase = "MappedSqlQuery";
-
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ISqlQuery sqlQuery,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("SqlQuery: ");
-
- if (sqlQuery.Schema != null)
- {
- builder
- .Append(sqlQuery.Schema)
- .Append(".");
- }
-
- builder.Append(sqlQuery.Name);
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- if (sqlQuery.Sql != null)
- {
- builder.AppendLine().Append(indentString).Append(" Sql: ");
- builder.AppendLine().Append(indentString).Append(new string(' ', 4)).Append(sqlQuery.Sql);
- }
-
- var mappings = sqlQuery.EntityTypeMappings.ToList();
- if (mappings.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
- foreach (var mapping in mappings)
- {
- builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
- }
- }
-
- var columns = sqlQuery.Columns.ToList();
- if (columns.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Columns: ");
- foreach (var column in columns)
- {
- builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
- }
- }
-
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(sqlQuery.AnnotationsToDebugString(indent + 2));
- }
- }
-
- return builder.ToString();
- }
+ [Obsolete("Use RelationalEntityTypeExtensions.DefaultQueryNameBase")]
+ public static readonly string DefaultQueryNameBase = RelationalEntityTypeExtensions.DefaultQueryNameBase;
}
}
diff --git a/src/EFCore.Relational/Metadata/SqlQueryMappingExtensions.cs b/src/EFCore.Relational/Metadata/SqlQueryMappingExtensions.cs
deleted file mode 100644
index eaec8f52469..00000000000
--- a/src/EFCore.Relational/Metadata/SqlQueryMappingExtensions.cs
+++ /dev/null
@@ -1,63 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class SqlQueryMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ISqlQueryMapping sqlQueryMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("SqlQueryMapping: ");
- }
-
- builder.Append(sqlQueryMapping.EntityType.Name).Append(" - ");
-
- builder.Append(sqlQueryMapping.Table.Name);
-
- if (sqlQueryMapping.IncludesDerivedTypes)
- {
- builder.Append(" IncludesDerivedTypes");
- }
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(sqlQueryMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/StoreFunctionExtensions.cs b/src/EFCore.Relational/Metadata/StoreFunctionExtensions.cs
deleted file mode 100644
index 2b5433ad44e..00000000000
--- a/src/EFCore.Relational/Metadata/StoreFunctionExtensions.cs
+++ /dev/null
@@ -1,109 +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.Linq;
-using System.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class StoreFunctionExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IStoreFunction function,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("StoreFunction: ");
-
- if (function.ReturnType != null)
- {
- builder.Append(function.ReturnType);
- }
- else
- {
- builder.Append(function.EntityTypeMappings.FirstOrDefault()?.EntityType.DisplayName() ?? "");
- }
-
- builder.Append(" ");
-
- if (function.Schema != null)
- {
- builder
- .Append(function.Schema)
- .Append(".");
- }
-
- builder.Append(function.Name);
-
- if (function.IsBuiltIn)
- {
- builder.Append(" IsBuiltIn");
- }
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- var parameters = function.Parameters.ToList();
- if (parameters.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Parameters: ");
- foreach (var parameter in parameters)
- {
- builder.AppendLine().Append(parameter.ToDebugString(options, indent + 4));
- }
- }
-
- var mappings = function.EntityTypeMappings.ToList();
- if (mappings.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
- foreach (var mapping in mappings)
- {
- builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
- }
- }
-
- var columns = function.Columns.ToList();
- if (columns.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Columns: ");
- foreach (var column in columns)
- {
- builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
- }
- }
-
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(function.AnnotationsToDebugString(indent: indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/StoreFunctionParameterExtensions.cs b/src/EFCore.Relational/Metadata/StoreFunctionParameterExtensions.cs
deleted file mode 100644
index 2f3451f0109..00000000000
--- a/src/EFCore.Relational/Metadata/StoreFunctionParameterExtensions.cs
+++ /dev/null
@@ -1,57 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class StoreFunctionParameterExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IStoreFunctionParameter parameter,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("StoreFunctionParameter: ");
-
- builder.Append(parameter.Name)
- .Append(" ")
- .Append(parameter.Type);
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(parameter.AnnotationsToDebugString(indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/TableExtensions.cs b/src/EFCore.Relational/Metadata/TableExtensions.cs
deleted file mode 100644
index 8f1788f9951..00000000000
--- a/src/EFCore.Relational/Metadata/TableExtensions.cs
+++ /dev/null
@@ -1,152 +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.Linq;
-using System.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class TableExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ITable table,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("Table: ");
-
- if (table.Schema != null)
- {
- builder
- .Append(table.Schema)
- .Append(".");
- }
-
- builder.Append(table.Name);
-
- if (table.IsExcludedFromMigrations)
- {
- builder.Append(" ExcludedFromMigrations");
- }
-
- if (table.PrimaryKey == null)
- {
- builder.Append(" Keyless");
- }
- else
- {
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- builder.AppendLine();
- }
-
- builder.Append(table.PrimaryKey.ToDebugString(options, indent + 2));
- }
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0 && table.Comment != null)
- {
- builder
- .AppendLine()
- .Append(indentString)
- .AppendLine(" Comment:")
- .Append(indentString)
- .Append(table.Comment);
- }
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- var mappings = table.EntityTypeMappings.ToList();
- if (mappings.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
- foreach (var mapping in mappings)
- {
- builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
- }
- }
-
- var columns = table.Columns.ToList();
- if (columns.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Columns: ");
- foreach (var column in columns)
- {
- builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
- }
- }
-
- var foreignKeyConstraints = table.ForeignKeyConstraints.ToList();
- if (foreignKeyConstraints.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" ForeignKeyConstraints: ");
- foreach (var foreignKeyConstraint in foreignKeyConstraints)
- {
- builder.AppendLine().Append(foreignKeyConstraint.ToDebugString(options, indent + 4));
- }
- }
-
- var indexes = table.Indexes.ToList();
- if (indexes.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Indexes: ");
- foreach (var index in indexes)
- {
- builder.AppendLine().Append(index.ToDebugString(options, indent + 4));
- }
- }
-
- var uniqueConstraints = table.UniqueConstraints.Where(uc => !uc.GetIsPrimaryKey()).ToList();
- if (uniqueConstraints.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" UniqueConstraints: ");
- foreach (var uniqueConstraint in uniqueConstraints)
- {
- builder.AppendLine().Append(uniqueConstraint.ToDebugString(options, indent + 4));
- }
- }
-
- var checkConstraints = table.CheckConstraints.ToList();
- if (checkConstraints.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Check constraints: ");
- foreach (var checkConstraint in checkConstraints)
- {
- builder.AppendLine().Append(checkConstraint.ToDebugString(options, indent + 4));
- }
- }
-
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(table.AnnotationsToDebugString(indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/TableIndexExtensions.cs b/src/EFCore.Relational/Metadata/TableIndexExtensions.cs
deleted file mode 100644
index f396466f4cb..00000000000
--- a/src/EFCore.Relational/Metadata/TableIndexExtensions.cs
+++ /dev/null
@@ -1,71 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata.Internal;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class TableIndexExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ITableIndex index,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("Index: ");
- }
-
- builder
- .Append(index.Name)
- .Append(" ")
- .Append(ColumnBase.Format(index.Columns));
-
- if (index.IsUnique)
- {
- builder
- .Append(" Unique");
- }
-
- if (!string.IsNullOrWhiteSpace(index.Filter))
- {
- builder
- .Append(" Filtered");
- }
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(index.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/TableMappingExtensions.cs b/src/EFCore.Relational/Metadata/TableMappingExtensions.cs
deleted file mode 100644
index 15a4bab23aa..00000000000
--- a/src/EFCore.Relational/Metadata/TableMappingExtensions.cs
+++ /dev/null
@@ -1,63 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class TableMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this ITableMapping tableMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("TableMapping: ");
- }
-
- builder.Append(tableMapping.EntityType.Name).Append(" - ");
-
- builder.Append(tableMapping.Table.Name);
-
- if (tableMapping.IncludesDerivedTypes)
- {
- builder.Append(" IncludesDerivedTypes");
- }
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(tableMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/UniqueConstraintExtensions.cs b/src/EFCore.Relational/Metadata/UniqueConstraintExtensions.cs
deleted file mode 100644
index daf6eb4a22f..00000000000
--- a/src/EFCore.Relational/Metadata/UniqueConstraintExtensions.cs
+++ /dev/null
@@ -1,72 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata.Internal;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class UniqueConstraintExtensions
- {
- ///
- /// Gets a value indicating whether this constraint is the primary key.
- ///
- /// The metadata item.
- /// if the constraint is the primary key
- public static bool GetIsPrimaryKey([NotNull] this IUniqueConstraint uniqueConstraint)
- => uniqueConstraint.Table.PrimaryKey == uniqueConstraint;
-
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IUniqueConstraint uniqueConstraint,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("Key: ");
- }
-
- builder
- .Append(uniqueConstraint.Name)
- .Append(" ")
- .Append(ColumnBase.Format(uniqueConstraint.Columns));
-
- if (uniqueConstraint.GetIsPrimaryKey())
- {
- builder.Append(" PrimaryKey");
- }
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(uniqueConstraint.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ViewColumnExtensions.cs b/src/EFCore.Relational/Metadata/ViewColumnExtensions.cs
deleted file mode 100644
index b8b533c202b..00000000000
--- a/src/EFCore.Relational/Metadata/ViewColumnExtensions.cs
+++ /dev/null
@@ -1,69 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class ViewColumnExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IViewColumn column,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append($"ViewColumn: {column.Table.Name}.");
- }
-
- builder.Append(column.Name).Append(" (");
-
- builder.Append(column.StoreType).Append(")");
-
- if (column.IsNullable)
- {
- builder.Append(" Nullable");
- }
- else
- {
- builder.Append(" NonNullable");
- }
-
- builder.Append(")");
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(column.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ViewColumnMappingExtensions.cs b/src/EFCore.Relational/Metadata/ViewColumnMappingExtensions.cs
deleted file mode 100644
index 1065474268e..00000000000
--- a/src/EFCore.Relational/Metadata/ViewColumnMappingExtensions.cs
+++ /dev/null
@@ -1,58 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class ViewColumnMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IViewColumnMapping columnMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("ViewColumnMapping: ");
- }
-
- builder.Append(columnMapping.Property.Name).Append(" - ");
-
- builder.Append(columnMapping.Column.Name);
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(columnMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ViewExtensions.cs b/src/EFCore.Relational/Metadata/ViewExtensions.cs
deleted file mode 100644
index 5bb1eda309f..00000000000
--- a/src/EFCore.Relational/Metadata/ViewExtensions.cs
+++ /dev/null
@@ -1,89 +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.Linq;
-using System.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class ViewExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IView view,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder
- .Append(indentString)
- .Append("View: ");
-
- if (view.Schema != null)
- {
- builder
- .Append(view.Schema)
- .Append(".");
- }
-
- builder.Append(view.Name);
-
- if ((options & MetadataDebugStringOptions.SingleLine) == 0)
- {
- if (view.ViewDefinitionSql != null)
- {
- builder.AppendLine().Append(indentString).Append(" DefinitionSql: ");
- builder.AppendLine().Append(indentString).Append(new string(' ', 4)).Append(view.ViewDefinitionSql);
- }
-
- var mappings = view.EntityTypeMappings.ToList();
- if (mappings.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" EntityTypeMappings: ");
- foreach (var mapping in mappings)
- {
- builder.AppendLine().Append(mapping.ToDebugString(options, indent + 4));
- }
- }
-
- var columns = view.Columns.ToList();
- if (columns.Count != 0)
- {
- builder.AppendLine().Append(indentString).Append(" Columns: ");
- foreach (var column in columns)
- {
- builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
- }
- }
-
- if ((options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(view.AnnotationsToDebugString(indent + 2));
- }
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Metadata/ViewMappingExtensions.cs b/src/EFCore.Relational/Metadata/ViewMappingExtensions.cs
deleted file mode 100644
index 2a0b74c7190..00000000000
--- a/src/EFCore.Relational/Metadata/ViewMappingExtensions.cs
+++ /dev/null
@@ -1,63 +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.Text;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Metadata
-{
- ///
- /// Extension methods for .
- ///
- public static class ViewMappingExtensions
- {
- ///
- ///
- /// Creates a human-readable representation of the given metadata.
- ///
- ///
- /// Warning: Do not rely on the format of the returned string.
- /// It is designed for debugging only and may change arbitrarily between releases.
- ///
- ///
- /// The metadata item.
- /// Options for generating the string.
- /// The number of indent spaces to use before each new line.
- /// A human-readable representation.
- public static string ToDebugString(
- [NotNull] this IViewMapping viewMapping,
- MetadataDebugStringOptions options,
- int indent = 0)
- {
- var builder = new StringBuilder();
- var indentString = new string(' ', indent);
-
- builder.Append(indentString);
-
- var singleLine = (options & MetadataDebugStringOptions.SingleLine) != 0;
- if (singleLine)
- {
- builder.Append("ViewMapping: ");
- }
-
- builder.Append(viewMapping.EntityType.Name).Append(" - ");
-
- builder.Append(viewMapping.Table.Name);
-
- if (viewMapping.IncludesDerivedTypes)
- {
- builder.Append(" IncludesDerivedTypes");
- }
-
- if (!singleLine && (options & MetadataDebugStringOptions.IncludeAnnotations) != 0)
- {
- builder.Append(viewMapping.AnnotationsToDebugString(indent + 2));
- }
-
- return builder.ToString();
- }
- }
-}
diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs
index 7d78b204a6e..cadbe27c778 100644
--- a/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs
+++ b/src/EFCore.Relational/Storage/RelationalTypeMappingInfo.cs
@@ -26,7 +26,7 @@ namespace Microsoft.EntityFrameworkCore.Storage
///
/// The property for which mapping is needed.
public RelationalTypeMappingInfo([NotNull] IProperty property)
- : this(property.FindPrincipals())
+ : this(property.GetPrincipals())
{
}
diff --git a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs
index 319d1556a1e..0bd40cf643f 100644
--- a/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs
+++ b/src/EFCore.Relational/Storage/RelationalTypeMappingSource.cs
@@ -200,7 +200,7 @@ protected override CoreTypeMapping FindMapping(in TypeMappingInfo mappingInfo)
/// The type mapping, or if none was found.
public override CoreTypeMapping? FindMapping(IProperty property)
{
- var principals = property.FindPrincipals();
+ var principals = property.GetPrincipals();
string? storeTypeName = null;
bool? isFixedLength = null;
diff --git a/src/EFCore/ChangeTracking/Internal/StateManager.cs b/src/EFCore/ChangeTracking/Internal/StateManager.cs
index ade7828ded5..d20f44b1ca3 100644
--- a/src/EFCore/ChangeTracking/Internal/StateManager.cs
+++ b/src/EFCore/ChangeTracking/Internal/StateManager.cs
@@ -323,7 +323,7 @@ private void UpdateReferenceMaps(
if (entityType.HasSharedClrType)
{
var mapKey = entry.Entity ?? entry;
- foreach (var otherType in _model.GetEntityTypes(entityType.ClrType)
+ foreach (var otherType in _model.FindEntityTypes(entityType.ClrType)
.Where(et => et != entityType && TryGetEntry(mapKey, et) != null))
{
UpdateLogger.DuplicateDependentEntityTypeInstanceWarning(entityType, otherType);
diff --git a/src/EFCore/Extensions/ConventionModelExtensions.cs b/src/EFCore/Extensions/ConventionModelExtensions.cs
index 4b730d655be..3c73d15f48e 100644
--- a/src/EFCore/Extensions/ConventionModelExtensions.cs
+++ b/src/EFCore/Extensions/ConventionModelExtensions.cs
@@ -19,6 +19,17 @@ namespace Microsoft.EntityFrameworkCore
[Obsolete("Use IConventionModel")]
public static class ConventionModelExtensions
{
+ ///
+ /// Gets the entity types matching the given type.
+ ///
+ /// The model to find the entity type in.
+ /// The type of the entity type to find.
+ /// The entity types found.
+ [DebuggerStepThrough]
+ [Obsolete("Use IConventionEntityType.FindEntityTypes")]
+ public static IEnumerable GetEntityTypes([NotNull] this IConventionModel model, [NotNull] Type type)
+ => model.FindEntityTypes(type);
+
///
/// Gets the entity types matching the given name.
///
@@ -26,7 +37,7 @@ public static class ConventionModelExtensions
/// The name of the entity type to find.
/// The entity types found.
[DebuggerStepThrough]
- [Obsolete("Use GetEntityTypes(Type) or FindEntityType(string)")]
+ [Obsolete("Use FindEntityTypes(Type) or FindEntityType(string)")]
public static IReadOnlyCollection GetEntityTypes(
[NotNull] this IConventionModel model,
[NotNull] string name)
diff --git a/src/EFCore/Extensions/ConventionPropertyExtensions.cs b/src/EFCore/Extensions/ConventionPropertyExtensions.cs
index 0109c0e359e..402b2fe6c99 100644
--- a/src/EFCore/Extensions/ConventionPropertyExtensions.cs
+++ b/src/EFCore/Extensions/ConventionPropertyExtensions.cs
@@ -2,6 +2,7 @@
// 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 JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata;
@@ -18,6 +19,16 @@ namespace Microsoft.EntityFrameworkCore
[Obsolete("Use IConventionProperty")]
public static class ConventionPropertyExtensions
{
+ ///
+ /// Finds the list of principal properties including the given property that the given property is constrained by
+ /// if the given property is part of a foreign key.
+ ///
+ /// The foreign key property.
+ /// The list of all associated principal properties including the given property.
+ [Obsolete("Use IConventionProperty.GetPrincipals")]
+ public static IReadOnlyList FindPrincipals([NotNull] this IConventionProperty property)
+ => property.GetPrincipals();
+
///
/// Sets the custom for this property when performing key comparisons.
///
diff --git a/src/EFCore/Extensions/ModelExtensions.cs b/src/EFCore/Extensions/ModelExtensions.cs
index 6e7d424b5f1..e2341d5d359 100644
--- a/src/EFCore/Extensions/ModelExtensions.cs
+++ b/src/EFCore/Extensions/ModelExtensions.cs
@@ -19,6 +19,17 @@ namespace Microsoft.EntityFrameworkCore
[Obsolete("Use IReadOnlyModel")]
public static class ModelExtensions
{
+ ///
+ /// Gets the entity types matching the given type.
+ ///
+ /// The model to find the entity type in.
+ /// The type of the entity type to find.
+ /// The entity types found.
+ [DebuggerStepThrough]
+ [Obsolete("Use IReadOnlyEntityType.FindEntityTypes")]
+ public static IEnumerable GetEntityTypes([NotNull] this IReadOnlyModel model, [NotNull] Type type)
+ => model.FindEntityTypes(type);
+
///
/// Gets the entity types matching the given name.
///
@@ -26,7 +37,7 @@ public static class ModelExtensions
/// The name of the entity type to find.
/// The entity types found.
[DebuggerStepThrough]
- [Obsolete("Use GetEntityTypes(Type) or FindEntityType(string)")]
+ [Obsolete("Use FindEntityTypes(Type) or FindEntityType(string)")]
public static IReadOnlyCollection GetEntityTypes([NotNull] this IReadOnlyModel model, [NotNull] string name)
=> ((Model)model).GetEntityTypes(name);
diff --git a/src/EFCore/Extensions/MutableModelExtensions.cs b/src/EFCore/Extensions/MutableModelExtensions.cs
index 550d9621289..9009f2b343a 100644
--- a/src/EFCore/Extensions/MutableModelExtensions.cs
+++ b/src/EFCore/Extensions/MutableModelExtensions.cs
@@ -19,6 +19,17 @@ namespace Microsoft.EntityFrameworkCore
[Obsolete("Use IMutableModel")]
public static class MutableModelExtensions
{
+ ///
+ /// Gets the entity types matching the given type.
+ ///
+ /// The model to find the entity type in.
+ /// The type of the entity type to find.
+ /// The entity types found.
+ [DebuggerStepThrough]
+ [Obsolete("Use IMutableEntityType.FindEntityTypes")]
+ public static IEnumerable GetEntityTypes([NotNull] this IMutableModel model, [NotNull] Type type)
+ => model.FindEntityTypes(type);
+
///
/// Gets the entity types matching the given name.
///
@@ -26,7 +37,7 @@ public static class MutableModelExtensions
/// The name of the entity type to find.
/// The entity types found.
[DebuggerStepThrough]
- [Obsolete("Use GetEntityTypes(Type) or FindEntityType(string)")]
+ [Obsolete("Use FindEntityTypes(Type) or FindEntityType(string)")]
public static IReadOnlyCollection GetEntityTypes([NotNull] this IMutableModel model, [NotNull] string name)
=> ((Model)model).GetEntityTypes(name);
}
diff --git a/src/EFCore/Extensions/MutablePropertyExtensions.cs b/src/EFCore/Extensions/MutablePropertyExtensions.cs
index 4d4c108e629..df43a726d76 100644
--- a/src/EFCore/Extensions/MutablePropertyExtensions.cs
+++ b/src/EFCore/Extensions/MutablePropertyExtensions.cs
@@ -2,6 +2,7 @@
// 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 JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata;
@@ -17,6 +18,16 @@ namespace Microsoft.EntityFrameworkCore
[Obsolete("Use IMutableProperty")]
public static class MutablePropertyExtensions
{
+ ///
+ /// Finds the list of principal properties including the given property that the given property is constrained by
+ /// if the given property is part of a foreign key.
+ ///
+ /// The foreign key property.
+ /// The list of all associated principal properties including the given property.
+ [Obsolete("Use IMutableProperty.GetPrincipals")]
+ public static IReadOnlyList FindPrincipals([NotNull] this IMutableProperty property)
+ => property.GetPrincipals();
+
///
/// Sets the custom for this property when performing key comparisons.
///
diff --git a/src/EFCore/Extensions/PropertyExtensions.cs b/src/EFCore/Extensions/PropertyExtensions.cs
index 739316a1b1e..06f2f87eec7 100644
--- a/src/EFCore/Extensions/PropertyExtensions.cs
+++ b/src/EFCore/Extensions/PropertyExtensions.cs
@@ -18,6 +18,16 @@ namespace Microsoft.EntityFrameworkCore
///
public static class PropertyExtensions
{
+ ///
+ /// Finds the list of principal properties including the given property that the given property is constrained by
+ /// if the given property is part of a foreign key.
+ ///
+ /// The foreign key property.
+ /// The list of all associated principal properties including the given property.
+ [Obsolete("Use IReadOnlyProperty.GetPrincipals")]
+ public static IReadOnlyList FindPrincipals([NotNull] this IReadOnlyProperty property)
+ => property.GetPrincipals();
+
///
/// Gets the to use for structural copies for this property, or if none is set.
///
diff --git a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs
index 2cbaeafb405..e34431cba84 100644
--- a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs
+++ b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs
@@ -127,7 +127,6 @@ public static readonly IDictionary CoreServices
{ typeof(IUpdateAdapterFactory), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(ICurrentDbContext), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(IDbContextDependencies), new ServiceCharacteristics(ServiceLifetime.Scoped) },
- { typeof(IModelCreationDependencies), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(IDatabaseFacadeDependencies), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(IDbContextOptions), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(IDatabase), new ServiceCharacteristics(ServiceLifetime.Scoped) },
@@ -239,7 +238,6 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices()
TryAdd();
TryAdd();
TryAdd();
- TryAdd();
TryAdd();
TryAdd();
TryAdd();
@@ -302,7 +300,7 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices()
.AddDependencySingleton()
.AddDependencySingleton()
.AddDependencySingleton()
- .AddDependencySingleton()
+ .AddDependencySingleton()
.AddDependencySingleton()
.AddDependencyScoped()
.AddDependencyScoped()
@@ -312,7 +310,8 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices()
.AddDependencyScoped()
.AddDependencyScoped()
.AddDependencyScoped()
- .AddDependencyScoped();
+ .AddDependencyScoped()
+ .AddDependencyScoped();
ServiceCollectionMap.TryAddSingleton(
new RegisteredServices(ServiceCollectionMap.ServiceCollection.Select(s => s.ServiceType)));
diff --git a/src/EFCore/Infrastructure/IModelCreationDependencies.cs b/src/EFCore/Infrastructure/IModelCreationDependencies.cs
deleted file mode 100644
index c3f090a58dd..00000000000
--- a/src/EFCore/Infrastructure/IModelCreationDependencies.cs
+++ /dev/null
@@ -1,53 +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 Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
-
-#nullable enable
-
-namespace Microsoft.EntityFrameworkCore.Infrastructure
-{
- ///
- ///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
- ///
- ///
- /// The service lifetime is . This means that each
- /// instance will use its own instance of this service.
- /// The implementation may depend on other services registered with any lifetime.
- /// The implementation does not need to be thread-safe.
- ///
- ///
- public interface IModelCreationDependencies
- {
- ///
- /// The model source.
- ///
- public IModelSource ModelSource { get; }
-
- ///
- /// The convention set to use when creating the model.
- ///
- public IConventionSetBuilder ConventionSetBuilder { get; }
-
- ///
- /// The dependencies object for the model.
- ///
- public ModelDependencies ModelDependencies { get; }
-
- ///
- /// The model runtime initializer that will be used after the model building is finished.
- ///
- public IModelRuntimeInitializer ModelRuntimeInitializer { get; }
-
- ///
- /// The validation logger.
- ///
- public IDiagnosticsLogger ValidationLogger { get; }
- }
-}
diff --git a/src/EFCore/Infrastructure/IModelSource.cs b/src/EFCore/Infrastructure/IModelSource.cs
index fd582f69408..9a601b4ffa6 100644
--- a/src/EFCore/Infrastructure/IModelSource.cs
+++ b/src/EFCore/Infrastructure/IModelSource.cs
@@ -60,6 +60,6 @@ IModel GetModel(
/// The model to be used.
IModel GetModel(
[NotNull] DbContext context,
- [NotNull] IModelCreationDependencies modelCreationDependencies);
+ [NotNull] ModelCreationDependencies modelCreationDependencies);
}
}
diff --git a/src/EFCore/Internal/ModelCreationDependencies.cs b/src/EFCore/Infrastructure/ModelCreationDependencies.cs
similarity index 60%
rename from src/EFCore/Internal/ModelCreationDependencies.cs
rename to src/EFCore/Infrastructure/ModelCreationDependencies.cs
index 027920cc3da..90865716d23 100644
--- a/src/EFCore/Internal/ModelCreationDependencies.cs
+++ b/src/EFCore/Infrastructure/ModelCreationDependencies.cs
@@ -8,7 +8,7 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;
-namespace Microsoft.EntityFrameworkCore.Internal
+namespace Microsoft.EntityFrameworkCore
{
///
///
@@ -24,7 +24,7 @@ namespace Microsoft.EntityFrameworkCore.Internal
/// The implementation does not need to be thread-safe.
///
///
- public sealed record ModelCreationDependencies : IModelCreationDependencies
+ public sealed record ModelCreationDependencies
{
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -53,42 +53,27 @@ public ModelCreationDependencies(
}
///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ /// The model source.
///
public IModelSource ModelSource { get; [param: NotNull] init; }
///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ /// The convention set to use when creating the model.
///
public IConventionSetBuilder ConventionSetBuilder { get; [param: NotNull] init; }
///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ /// The dependencies object for the model.
///
public ModelDependencies ModelDependencies { get; [param: NotNull] init; }
///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ /// The model runtime initializer that will be used after the model building is finished.
///
public IModelRuntimeInitializer ModelRuntimeInitializer { get; [param: NotNull] init; }
///
- /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
- /// the same compatibility standards as public APIs. It may be changed or removed without notice in
- /// any release. You should only use it directly in your code with extreme caution and knowing that
- /// doing so can result in application failures when updating to a new Entity Framework Core release.
+ /// The validation logger.
///
public IDiagnosticsLogger ValidationLogger { get; [param: NotNull] init; }
}
diff --git a/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs b/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs
index 1873857b413..04b3dd85be0 100644
--- a/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs
+++ b/src/EFCore/Infrastructure/ModelRuntimeInitializer.cs
@@ -54,8 +54,10 @@ public virtual IModel Initialize(
IModel model,
IDiagnosticsLogger? validationLogger)
{
- if (model.SetModelDependencies(Dependencies.ModelDependencies))
+ if (model.ModelDependencies == null)
{
+ model.ModelDependencies = Dependencies.ModelDependencies;
+
InitializeModel(model, preValidation: true);
if (validationLogger != null
diff --git a/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs b/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs
index 60bea6f40a2..2893d0d204f 100644
--- a/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs
+++ b/src/EFCore/Infrastructure/ModelRuntimeInitializerDependencies.cs
@@ -55,7 +55,7 @@ public sealed record ModelRuntimeInitializerDependencies
///
[EntityFrameworkInternal]
public ModelRuntimeInitializerDependencies(
- [NotNull] SingletonModelDependencies singletonModelDependencies,
+ [NotNull] RuntimeModelDependencies singletonModelDependencies,
[NotNull] IModelValidator modelValidator)
{
Check.NotNull(singletonModelDependencies, nameof(singletonModelDependencies));
@@ -68,7 +68,7 @@ public ModelRuntimeInitializerDependencies(
///
/// The model runtime dependencies.
///
- public SingletonModelDependencies ModelDependencies { get; [param: NotNull] init; }
+ public RuntimeModelDependencies ModelDependencies { get; [param: NotNull] init; }
///
/// The model validator.
diff --git a/src/EFCore/Infrastructure/ModelSource.cs b/src/EFCore/Infrastructure/ModelSource.cs
index 3fe3b06485b..79a10dfd0da 100644
--- a/src/EFCore/Infrastructure/ModelSource.cs
+++ b/src/EFCore/Infrastructure/ModelSource.cs
@@ -117,7 +117,7 @@ public virtual IModel GetModel(
/// The model to be used.
public virtual IModel GetModel(
DbContext context,
- IModelCreationDependencies modelCreationDependencies)
+ ModelCreationDependencies modelCreationDependencies)
{
var cache = Dependencies.MemoryCache;
var cacheKey = Dependencies.ModelCacheKeyFactory.Create(context);
diff --git a/src/EFCore/Infrastructure/NavigationBaseExtensions.cs b/src/EFCore/Infrastructure/NavigationBaseExtensions.cs
new file mode 100644
index 00000000000..4689630a9cb
--- /dev/null
+++ b/src/EFCore/Infrastructure/NavigationBaseExtensions.cs
@@ -0,0 +1,22 @@
+// 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;
+using Microsoft.EntityFrameworkCore.Metadata;
+
+namespace Microsoft.EntityFrameworkCore.Infrastructure
+{
+ ///
+ ///
+ /// Extension methods for .
+ ///
+ ///
+ /// This type is typically used by database providers (and other extensions). It is generally
+ /// not used in application code.
+ ///
+ ///
+ [Obsolete("Use INavigationBase")]
+ public static class NavigationBaseExtensions
+ {
+ }
+}
diff --git a/src/EFCore/Infrastructure/SingletonModelDependencies.cs b/src/EFCore/Infrastructure/RuntimeModelDependencies.cs
similarity index 97%
rename from src/EFCore/Infrastructure/SingletonModelDependencies.cs
rename to src/EFCore/Infrastructure/RuntimeModelDependencies.cs
index 374ab522e50..a6eecc9eb0a 100644
--- a/src/EFCore/Infrastructure/SingletonModelDependencies.cs
+++ b/src/EFCore/Infrastructure/RuntimeModelDependencies.cs
@@ -32,7 +32,7 @@ namespace Microsoft.EntityFrameworkCore.Infrastructure
/// The implementation does not need to be thread-safe.
///
///
- public sealed record SingletonModelDependencies
+ public sealed record RuntimeModelDependencies
{
///
///
@@ -54,7 +54,7 @@ public sealed record SingletonModelDependencies
///
///
[EntityFrameworkInternal]
- public SingletonModelDependencies(
+ public RuntimeModelDependencies(
[NotNull] ITypeMappingSource typeMappingSource,
[NotNull] IConstructorBindingFactory constructorBindingFactory,
[NotNull] IParameterBindingFactories parameterBindingFactories)
diff --git a/src/EFCore/Internal/DbContextServices.cs b/src/EFCore/Internal/DbContextServices.cs
index 225438f487e..0b617675653 100644
--- a/src/EFCore/Internal/DbContextServices.cs
+++ b/src/EFCore/Internal/DbContextServices.cs
@@ -87,7 +87,7 @@ private IModel CreateModel(IModel modelFromOptions)
{
_inOnModelCreating = true;
- var dependencies = _scopedProvider.GetService();
+ var dependencies = _scopedProvider.GetService();
return modelFromOptions == null
? dependencies.ModelSource.GetModel(_currentContext.Context, dependencies)
: dependencies.ModelRuntimeInitializer.Initialize(modelFromOptions, dependencies.ValidationLogger);
diff --git a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs
index c622bb48ced..76acab3bae1 100644
--- a/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs
+++ b/src/EFCore/Metadata/Conventions/InversePropertyAttributeConvention.cs
@@ -248,9 +248,9 @@ private void Process(
&& !entityType.IsInOwnershipPath(targetEntityTypeBuilder.Metadata))
{
if (navigationMemberInfo.DeclaringType != entityType.ClrType
- && (entityType.Model.GetEntityTypes(navigationMemberInfo.DeclaringType!).Any()
+ && (entityType.Model.FindEntityTypes(navigationMemberInfo.DeclaringType!).Any()
|| (navigationMemberInfo.DeclaringType != entityType.ClrType.BaseType
- && entityType.Model.GetEntityTypes(entityType.ClrType.BaseType!).Any())))
+ && entityType.Model.FindEntityTypes(entityType.ClrType.BaseType!).Any())))
{
return null;
}
diff --git a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
index 84659e676ed..2b88eb80c02 100644
--- a/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
+++ b/src/EFCore/Metadata/Conventions/RelationshipDiscoveryConvention.cs
@@ -623,7 +623,7 @@ private void CreateRelationships(
var targetOwned = (!entityType.IsInOwnershipPath(targetEntityType)
&& (targetEntityType.Model.IsOwned(targetEntityType.ClrType)
|| (targetEntityType.HasSharedClrType
- && targetEntityType.Model.GetEntityTypes(targetEntityType.ClrType).Any(e => e.IsOwned()))));
+ && targetEntityType.Model.FindEntityTypes(targetEntityType.ClrType).Any(e => e.IsOwned()))));
var inverse = relationshipCandidate.InverseProperties.SingleOrDefault();
if (inverse == null)
diff --git a/src/EFCore/Metadata/IConventionModel.cs b/src/EFCore/Metadata/IConventionModel.cs
index ce5291c7c8a..6aeee28224d 100644
--- a/src/EFCore/Metadata/IConventionModel.cs
+++ b/src/EFCore/Metadata/IConventionModel.cs
@@ -248,8 +248,8 @@ public interface IConventionModel : IReadOnlyModel, IConventionAnnotatable
///
/// The type of the entity type to find.
/// The entity types found.
- new IEnumerable GetEntityTypes([NotNull] Type type)
- => ((IReadOnlyModel)this).GetEntityTypes(type).Cast();
+ new IEnumerable FindEntityTypes([NotNull] Type type)
+ => ((IReadOnlyModel)this).FindEntityTypes(type).Cast();
///
/// Returns the entity types corresponding to the least derived types from the given one.
@@ -257,10 +257,10 @@ public interface IConventionModel : IReadOnlyModel, IConventionAnnotatable
/// The base type.
/// An optional condition for filtering entity types.
/// List of entity types corresponding to the least derived types from the given one.
- IEnumerable FindLeastDerivedEntityTypes(
+ new IEnumerable FindLeastDerivedEntityTypes(
[NotNull] Type type,
- [CanBeNull] Func? condition = null)
- => ((IReadOnlyModel)this).FindLeastDerivedEntityTypes(type, condition == null ? null : t => condition((IConventionEntityType)t))
+ [CanBeNull] Func? condition = null)
+ => ((IReadOnlyModel)this).FindLeastDerivedEntityTypes(type, condition == null ? null : t => condition(t))
.Cast();
///
diff --git a/src/EFCore/Metadata/IConventionProperty.cs b/src/EFCore/Metadata/IConventionProperty.cs
index 4fd765589f6..b72bddff503 100644
--- a/src/EFCore/Metadata/IConventionProperty.cs
+++ b/src/EFCore/Metadata/IConventionProperty.cs
@@ -123,8 +123,8 @@ bool IsImplicitlyCreated()
/// if the given property is part of a foreign key.
///
/// The list of all associated principal properties including the given property.
- new IReadOnlyList FindPrincipals()
- => ((IReadOnlyProperty)this).FindPrincipals().Cast().ToList();
+ new IReadOnlyList GetPrincipals()
+ => ((IReadOnlyProperty)this).GetPrincipals().Cast().ToList();
///
/// Gets all foreign keys that use this property (including composite foreign keys in which this property
diff --git a/src/EFCore/Metadata/IForeignKey.cs b/src/EFCore/Metadata/IForeignKey.cs
index 08f5caf9d87..54a670a561b 100644
--- a/src/EFCore/Metadata/IForeignKey.cs
+++ b/src/EFCore/Metadata/IForeignKey.cs
@@ -63,7 +63,7 @@ public interface IForeignKey : IReadOnlyForeignKey, IAnnotatable
///
/// One of the entity types related by the foreign key.
/// The entity type related to the given one.
- IEntityType GetRelatedEntityType([NotNull] IEntityType entityType)
+ new IEntityType GetRelatedEntityType([NotNull] IReadOnlyEntityType entityType)
=> (IEntityType)((IReadOnlyForeignKey)this).GetRelatedEntityType(entityType);
///
diff --git a/src/EFCore/Metadata/IModel.cs b/src/EFCore/Metadata/IModel.cs
index 672fd809791..e0b84a4df97 100644
--- a/src/EFCore/Metadata/IModel.cs
+++ b/src/EFCore/Metadata/IModel.cs
@@ -12,6 +12,7 @@
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;
+using CA = System.Diagnostics.CodeAnalysis;
#nullable enable
@@ -82,13 +83,18 @@ public interface IModel : IReadOnlyModel, IAnnotatable
///
/// The runtime service dependencies.
///
- SingletonModelDependencies? ModelDependencies
- => (SingletonModelDependencies?)FindRuntimeAnnotationValue(CoreAnnotationNames.ModelDependencies);
+ [CA.DisallowNull]
+ RuntimeModelDependencies? ModelDependencies
+ {
+ get => (RuntimeModelDependencies?)FindRuntimeAnnotationValue(CoreAnnotationNames.ModelDependencies);
+ [param: NotNull]
+ set => SetRuntimeAnnotation(CoreAnnotationNames.ModelDependencies, Check.NotNull(value, nameof(value)));
+ }
///
/// Gets the runtime service dependencies.
///
- SingletonModelDependencies GetModelDependencies()
+ RuntimeModelDependencies GetModelDependencies()
{
var dependencies = ModelDependencies;
if (dependencies == null)
@@ -99,23 +105,6 @@ SingletonModelDependencies GetModelDependencies()
return dependencies;
}
- ///
- /// Set the runtime service dependencies.
- ///
- /// The runtime service dependencies.
- /// if the runtime service dependencies were set; otherwise.
- bool SetModelDependencies([NotNull] SingletonModelDependencies modelDependencies)
- {
- if (FindRuntimeAnnotation(CoreAnnotationNames.ModelDependencies) != null)
- {
- return false;
- }
-
- AddRuntimeAnnotation(CoreAnnotationNames.ModelDependencies, modelDependencies);
-
- return true;
- }
-
///
/// Gets the entity that maps the given entity class. Returns if no entity type with
/// the given CLR type is found or the given CLR type is being used by shared type entity type
@@ -145,7 +134,7 @@ bool SetModelDependencies([NotNull] SingletonModelDependencies modelDependencies
/// The type of the entity type to find.
/// The entity types found.
[DebuggerStepThrough]
- new IEnumerable GetEntityTypes([NotNull] Type type);
+ new IEnumerable FindEntityTypes([NotNull] Type type);
///
/// Returns the entity types corresponding to the least derived types from the given.
@@ -153,10 +142,10 @@ bool SetModelDependencies([NotNull] SingletonModelDependencies modelDependencies
/// The base type.
/// An optional condition for filtering entity types.
/// List of entity types corresponding to the least derived types from the given.
- IEnumerable FindLeastDerivedEntityTypes(
+ new IEnumerable FindLeastDerivedEntityTypes(
[NotNull] Type type,
- [CanBeNull] Func? condition = null)
- => ((IReadOnlyModel)this).FindLeastDerivedEntityTypes(type, condition == null ? null : t => condition((IEntityType)t))
+ [CanBeNull] Func? condition = null)
+ => ((IReadOnlyModel)this).FindLeastDerivedEntityTypes(type, condition == null ? null : t => condition(t))
.Cast();
///
diff --git a/src/EFCore/Metadata/IMutableModel.cs b/src/EFCore/Metadata/IMutableModel.cs
index 2b568f5365b..c14305bae7f 100644
--- a/src/EFCore/Metadata/IMutableModel.cs
+++ b/src/EFCore/Metadata/IMutableModel.cs
@@ -220,8 +220,8 @@ IMutableEntityType AddEntityType(
///
/// The type of the entity type to find.
/// The entity types found.
- new IEnumerable GetEntityTypes([NotNull] Type type)
- => ((IReadOnlyModel)this).GetEntityTypes(type).Cast();
+ new IEnumerable FindEntityTypes([NotNull] Type type)
+ => ((IReadOnlyModel)this).FindEntityTypes(type).Cast();
///
/// Returns the entity types corresponding to the least derived types from the given one.
@@ -229,10 +229,10 @@ IMutableEntityType AddEntityType(
/// The base type.
/// An optional condition for filtering entity types.
/// List of entity types corresponding to the least derived types from the given one.
- IEnumerable FindLeastDerivedEntityTypes(
+ new IEnumerable FindLeastDerivedEntityTypes(
[NotNull] Type type,
- [CanBeNull] Func? condition = null)
- => ((IReadOnlyModel)this).FindLeastDerivedEntityTypes(type, condition == null ? null : t => condition((IMutableEntityType)t))
+ [CanBeNull] Func? condition = null)
+ => ((IReadOnlyModel)this).FindLeastDerivedEntityTypes(type, condition == null ? null : t => condition(t))
.Cast();
///
diff --git a/src/EFCore/Metadata/IMutableProperty.cs b/src/EFCore/Metadata/IMutableProperty.cs
index 227c2913594..faba26de115 100644
--- a/src/EFCore/Metadata/IMutableProperty.cs
+++ b/src/EFCore/Metadata/IMutableProperty.cs
@@ -66,8 +66,8 @@ public interface IMutableProperty : IReadOnlyProperty, IMutablePropertyBase
/// if the given property is part of a foreign key.
///
/// The list of all associated principal properties including the given property.
- new IReadOnlyList FindPrincipals()
- => ((IReadOnlyProperty)this).FindPrincipals().Cast().ToList();
+ new IReadOnlyList GetPrincipals()
+ => ((IReadOnlyProperty)this).GetPrincipals().Cast().ToList();
///
/// Gets all foreign keys that use this property (including composite foreign keys in which this property
diff --git a/src/EFCore/Metadata/IProperty.cs b/src/EFCore/Metadata/IProperty.cs
index e57237f51f4..7d43bc2fe84 100644
--- a/src/EFCore/Metadata/IProperty.cs
+++ b/src/EFCore/Metadata/IProperty.cs
@@ -63,8 +63,8 @@ public int GetHashCode(TNullableKey obj)
/// if the given property is part of a foreign key.
///
/// The list of all associated principal properties including the given property.
- new IReadOnlyList FindPrincipals()
- => ((IReadOnlyProperty)this).FindPrincipals().Cast().ToList();
+ new IReadOnlyList GetPrincipals()
+ => ((IReadOnlyProperty)this).GetPrincipals().Cast().ToList();
///
/// Gets all foreign keys that use this property (including composite foreign keys in which this property
diff --git a/src/EFCore/Metadata/IReadOnlyModel.cs b/src/EFCore/Metadata/IReadOnlyModel.cs
index ec02f1a56cf..ef2ddafcb79 100644
--- a/src/EFCore/Metadata/IReadOnlyModel.cs
+++ b/src/EFCore/Metadata/IReadOnlyModel.cs
@@ -110,7 +110,7 @@ public interface IReadOnlyModel : IReadOnlyAnnotatable
///
/// The type of the entity type to find.
/// The entity types found.
- IEnumerable GetEntityTypes([NotNull] Type type);
+ IEnumerable FindEntityTypes([NotNull] Type type);
///
/// Returns the entity types corresponding to the least derived types from the given.
diff --git a/src/EFCore/Metadata/IReadOnlyProperty.cs b/src/EFCore/Metadata/IReadOnlyProperty.cs
index 0d8416c179c..7a1fdac337b 100644
--- a/src/EFCore/Metadata/IReadOnlyProperty.cs
+++ b/src/EFCore/Metadata/IReadOnlyProperty.cs
@@ -190,7 +190,7 @@ CoreTypeMapping GetTypeMapping()
/// if the given property is part of a foreign key.
///
/// The list of all associated principal properties including the given property.
- IReadOnlyList FindPrincipals()
+ IReadOnlyList GetPrincipals()
{
var principals = new List { this };
AddPrincipals(this, principals);
diff --git a/src/EFCore/Metadata/Internal/IRuntimeSkipNavigation.cs b/src/EFCore/Metadata/Internal/IRuntimeSkipNavigation.cs
index a42369eaa87..c2576ee5dcd 100644
--- a/src/EFCore/Metadata/Internal/IRuntimeSkipNavigation.cs
+++ b/src/EFCore/Metadata/Internal/IRuntimeSkipNavigation.cs
@@ -1,10 +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.
-#nullable enable
-
using Microsoft.EntityFrameworkCore.Internal;
+#nullable enable
+
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
{
///
diff --git a/src/EFCore/Metadata/Internal/InternalModelBuilder.cs b/src/EFCore/Metadata/Internal/InternalModelBuilder.cs
index d7d86085805..fa1e85e1f5b 100644
--- a/src/EFCore/Metadata/Internal/InternalModelBuilder.cs
+++ b/src/EFCore/Metadata/Internal/InternalModelBuilder.cs
@@ -282,7 +282,7 @@ public override InternalModelBuilder ModelBuilder
Metadata.RemoveIgnored(type);
Metadata.AddOwned(type, ConfigurationSource.Explicit);
- foreach (var entityType in Metadata.GetEntityTypes(type))
+ foreach (var entityType in Metadata.FindEntityTypes(type))
{
if (entityType.IsOwned())
{
@@ -474,7 +474,7 @@ private bool CanIgnore(in TypeIdentity type, ConfigurationSource configurationSo
}
if (type.Type != null
- && Metadata.GetEntityTypes(type.Type).Any(o => !configurationSource.Overrides(o.GetConfigurationSource())))
+ && Metadata.FindEntityTypes(type.Type).Any(o => !configurationSource.Overrides(o.GetConfigurationSource())))
{
return false;
}
diff --git a/src/EFCore/Metadata/Internal/KeyExtensions.cs b/src/EFCore/Metadata/Internal/KeyExtensions.cs
index 5406beaa85a..4de8e011923 100644
--- a/src/EFCore/Metadata/Internal/KeyExtensions.cs
+++ b/src/EFCore/Metadata/Internal/KeyExtensions.cs
@@ -1,10 +1,7 @@
// 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;
-using System.Runtime.CompilerServices;
using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
#nullable enable
diff --git a/src/EFCore/Metadata/Internal/Model.cs b/src/EFCore/Metadata/Internal/Model.cs
index 979d19d6966..5c7193c6b34 100644
--- a/src/EFCore/Metadata/Internal/Model.cs
+++ b/src/EFCore/Metadata/Internal/Model.cs
@@ -44,7 +44,7 @@ public class Model : ConventionAnnotatable, IMutableModel, IConventionModel, IRu
///
public static readonly Type DefaultPropertyBagType = typeof(Dictionary);
- private SingletonModelDependencies? _modelDependencies;
+ private RuntimeModelDependencies? _modelDependencies;
private readonly SortedDictionary _entityTypes = new(StringComparer.Ordinal);
private readonly ConcurrentDictionary _indexerPropertyInfoMap = new();
private readonly ConcurrentDictionary _clrTypeNameMap = new();
@@ -449,7 +449,7 @@ public virtual string GetDisplayName([NotNull] Type type)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual IEnumerable GetEntityTypes([NotNull] Type type)
+ public virtual IEnumerable FindEntityTypes([NotNull] Type type)
{
var result = GetEntityTypes(GetDisplayName(type));
return _sharedTypes.TryGetValue(type, out var existingTypes)
@@ -955,7 +955,7 @@ public virtual object? RelationalModel
///
/// The runtime service dependencies.
///
- SingletonModelDependencies? IModel.ModelDependencies
+ RuntimeModelDependencies? IModel.ModelDependencies
{
get
{
@@ -966,6 +966,12 @@ public virtual object? RelationalModel
return _modelDependencies;
}
+ set
+ {
+ Check.NotNull(value, nameof(value));
+
+ _modelDependencies = value;
+ }
}
///
@@ -1220,8 +1226,8 @@ IEnumerable IModel.GetEntityTypes()
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
[DebuggerStepThrough]
- IEnumerable IReadOnlyModel.GetEntityTypes(Type type)
- => GetEntityTypes(type);
+ IEnumerable IReadOnlyModel.FindEntityTypes(Type type)
+ => FindEntityTypes(type);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -1230,8 +1236,8 @@ IEnumerable IReadOnlyModel.GetEntityTypes(Type type)
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
[DebuggerStepThrough]
- IEnumerable IModel.GetEntityTypes(Type type)
- => GetEntityTypes(type);
+ IEnumerable IModel.FindEntityTypes(Type type)
+ => FindEntityTypes(type);
///
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
@@ -1536,14 +1542,5 @@ string IMutableModel.AddIgnored([NotNull] Type type)
[DebuggerStepThrough]
string? IConventionModel.AddIgnored(Type type, bool fromDataAnnotation)
=> AddIgnored(type, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
-
- ///
- /// Set the runtime service dependencies.
- ///
- /// The runtime service dependencies.
- /// if the runtime service dependencies were set; otherwise.
- [DebuggerStepThrough]
- bool IModel.SetModelDependencies(SingletonModelDependencies modelDependencies)
- => Interlocked.CompareExchange(ref _modelDependencies, modelDependencies, null) == null;
}
}
diff --git a/src/EFCore/Storage/TypeMappingInfo.cs b/src/EFCore/Storage/TypeMappingInfo.cs
index 662e4932180..d50b4934b38 100644
--- a/src/EFCore/Storage/TypeMappingInfo.cs
+++ b/src/EFCore/Storage/TypeMappingInfo.cs
@@ -23,7 +23,7 @@ namespace Microsoft.EntityFrameworkCore.Storage
///
/// The property for which mapping is needed.
public TypeMappingInfo([NotNull] IProperty property)
- : this(property.FindPrincipals())
+ : this(property.GetPrincipals())
{
}
diff --git a/src/EFCore/Storage/TypeMappingSource.cs b/src/EFCore/Storage/TypeMappingSource.cs
index 66a534b5cdd..7d165849c1e 100644
--- a/src/EFCore/Storage/TypeMappingSource.cs
+++ b/src/EFCore/Storage/TypeMappingSource.cs
@@ -149,7 +149,7 @@ protected TypeMappingSource([NotNull] TypeMappingSourceDependencies dependencies
/// The type mapping, or if none was found.
public override CoreTypeMapping? FindMapping(IProperty property)
{
- var principals = property.FindPrincipals();
+ var principals = property.GetPrincipals();
return FindMappingWithConversion(new TypeMappingInfo(principals), principals);
}
diff --git a/test/EFCore.Tests/DbContextServicesTest.cs b/test/EFCore.Tests/DbContextServicesTest.cs
index 5090b5fb77a..89a673a8b9e 100644
--- a/test/EFCore.Tests/DbContextServicesTest.cs
+++ b/test/EFCore.Tests/DbContextServicesTest.cs
@@ -662,7 +662,7 @@ public IModel GetModel(
public IModel GetModel(
DbContext context,
- IModelCreationDependencies modelCreationDependencies)
+ ModelCreationDependencies modelCreationDependencies)
=> new Model();
}
diff --git a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs
index 2b41b0bf3e7..e71223add08 100644
--- a/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs
+++ b/test/EFCore.Tests/Metadata/Internal/InternalModelBuilderTest.cs
@@ -310,7 +310,7 @@ public void Can_mark_type_as_owned_type()
Assert.NotNull(modelBuilder.Ignore(typeof(Details), ConfigurationSource.Convention));
- Assert.Empty(model.GetEntityTypes(typeof(Details)));
+ Assert.Empty(model.FindEntityTypes(typeof(Details)));
Assert.Null(entityBuilder.HasOwnership(typeof(Details), nameof(Customer.Details), ConfigurationSource.Convention));
@@ -330,7 +330,7 @@ public void Can_mark_type_as_owned_type()
Assert.Null(modelBuilder.Ignore(typeof(Details), ConfigurationSource.Convention));
- Assert.Equal(2, model.GetEntityTypes(typeof(Details)).Count());
+ Assert.Equal(2, model.FindEntityTypes(typeof(Details)).Count());
Assert.Equal(
CoreStrings.ClashingSharedType(typeof(Details).Name),
@@ -347,7 +347,7 @@ public void Can_mark_type_as_owned_type()
Assert.NotNull(modelBuilder.SharedTypeEntity(nameof(Details), typeof(Details), ConfigurationSource.Explicit));
- Assert.Empty(model.GetEntityTypes(typeof(Details)).Where(e => !e.HasSharedClrType));
+ Assert.Empty(model.FindEntityTypes(typeof(Details)).Where(e => !e.HasSharedClrType));
Assert.Null(modelBuilder.Owned(typeof(Details), ConfigurationSource.Convention));
diff --git a/test/EFCore.Tests/Metadata/Internal/KeyTest.cs b/test/EFCore.Tests/Metadata/Internal/KeyTest.cs
index 86df58171ac..e8e43549a47 100644
--- a/test/EFCore.Tests/Metadata/Internal/KeyTest.cs
+++ b/test/EFCore.Tests/Metadata/Internal/KeyTest.cs
@@ -2,11 +2,9 @@
// 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.Linq;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Diagnostics;
-using Microsoft.EntityFrameworkCore.Infrastructure;
using Xunit;
namespace Microsoft.EntityFrameworkCore.Metadata.Internal
diff --git a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs
index d2bbf88bdd6..8fde3059d68 100644
--- a/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs
+++ b/test/EFCore.Tests/ModelBuilding/OwnedTypesTestBase.cs
@@ -504,7 +504,7 @@ public virtual void Can_configure_one_to_one_relationship_from_an_owned_type_col
Assert.Null(foreignKey.PrincipalToDependent);
Assert.NotEqual(ownership1.Properties.Single().Name, foreignKey.Properties.Single().Name);
Assert.Equal(5, model.GetEntityTypes().Count());
- Assert.Equal(2, model.GetEntityTypes(typeof(Order)).Count());
+ Assert.Equal(2, model.FindEntityTypes(typeof(Order)).Count());
Assert.Equal(2, ownership1.DeclaringEntityType.GetForeignKeys().Count());
Assert.Equal(2, model.GetEntityTypes().Count(e => e.ClrType == typeof(Order)));
@@ -786,7 +786,7 @@ public virtual void Can_configure_owned_type_collection_with_one_call()
nameof(SpecialOrder.SpecialOrderId), specialOwnership.DeclaringEntityType.FindPrimaryKey().Properties.Single().Name);
Assert.Equal(9, modelBuilder.Model.GetEntityTypes().Count());
- Assert.Equal(2, modelBuilder.Model.GetEntityTypes(typeof(Order)).Count());
+ Assert.Equal(2, modelBuilder.Model.FindEntityTypes(typeof(Order)).Count());
Assert.Equal(7, modelBuilder.Model.GetEntityTypes().Count(e => !e.HasSharedClrType));
Assert.Equal(5, modelBuilder.Model.GetEntityTypes().Count(e => e.IsOwned()));
@@ -834,7 +834,7 @@ public virtual void Can_configure_owned_type_collection_with_one_call_afterwards
nameof(SpecialOrder.SpecialOrderId), specialOwnership.DeclaringEntityType.FindPrimaryKey().Properties.Single().Name);
Assert.Equal(9, modelBuilder.Model.GetEntityTypes().Count());
- Assert.Equal(2, modelBuilder.Model.GetEntityTypes(typeof(Order)).Count());
+ Assert.Equal(2, modelBuilder.Model.FindEntityTypes(typeof(Order)).Count());
// SpecialOrder and Address are only used once, but once they are made shared they don't revert to non-shared
Assert.Equal(5, modelBuilder.Model.GetEntityTypes().Count(e => !e.HasSharedClrType));
Assert.Equal(5, modelBuilder.Model.GetEntityTypes().Count(e => e.IsOwned()));
@@ -1400,7 +1400,7 @@ public virtual void OwnedType_can_derive_from_Collection()
var model = modelBuilder.FinalizeModel();
- Assert.Single(model.GetEntityTypes(typeof(List)));
+ Assert.Single(model.FindEntityTypes(typeof(List)));
}
[ConditionalFact]
diff --git a/test/EFCore.Tests/ModelSourceTest.cs b/test/EFCore.Tests/ModelSourceTest.cs
index 43cd397fc50..a827a9993ac 100644
--- a/test/EFCore.Tests/ModelSourceTest.cs
+++ b/test/EFCore.Tests/ModelSourceTest.cs
@@ -72,7 +72,7 @@ public void Adds_all_entities_based_on_all_distinct_entity_types_found()
var model = serviceProvider.GetRequiredService()
.GetModel(
new Context1(),
- (serviceProvider.GetRequiredService() as ModelCreationDependencies)
+ serviceProvider.GetRequiredService()
with { ConventionSetBuilder = CreateRuntimeConventionSetBuilder(new FakeSetFinder(), serviceProvider) });
Assert.Equal(
@@ -121,7 +121,7 @@ public void Caches_model_by_context_type()
{
var serviceProvider = InMemoryTestHelpers.Instance.CreateContextServices();
var modelSource = serviceProvider.GetRequiredService();
- var testModelDependencies = serviceProvider.GetRequiredService();
+ var testModelDependencies = serviceProvider.GetRequiredService();
var model1 = modelSource.GetModel(new Context1(), testModelDependencies);
var model2 = modelSource.GetModel(new Context2(), testModelDependencies);
@@ -136,7 +136,7 @@ public void Stores_model_version_information_as_annotation_on_model()
{
var serviceProvider = InMemoryTestHelpers.Instance.CreateContextServices();
var modelSource = serviceProvider.GetRequiredService();
- var testModelDependencies = serviceProvider.GetRequiredService();
+ var testModelDependencies = serviceProvider.GetRequiredService();
var model = modelSource.GetModel(new Context1(), testModelDependencies);
var packageVersion = typeof(Context1).Assembly.GetCustomAttributes()