Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/EFCore.Relational/Extensions/RelationalModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ public static string ToDebugString(
var builder = new StringBuilder();
var indentString = new string(' ', indent);

builder.Append(indentString).Append("DatabaseModel: ");
builder.Append(indentString).Append("RelationalModel: ");

if (model.Collation != null)
{
builder.AppendLine().Append(indentString).Append("Collation: " + model.Collation);
}

foreach (var table in model.Tables)
{
Expand All @@ -53,6 +58,21 @@ public static string ToDebugString(
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));
Expand Down
8 changes: 7 additions & 1 deletion src/EFCore.Relational/Metadata/SqlQueryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public static string ToDebugString(

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);
Comment thread
AndriySvyryd marked this conversation as resolved.
}

var mappings = sqlQuery.EntityTypeMappings.ToList();
if (mappings.Count != 0)
{
Expand All @@ -68,7 +74,7 @@ public static string ToDebugString(
var columns = sqlQuery.Columns.ToList();
if (columns.Count != 0)
{
builder.AppendLine().Append(indentString).Append(" Properties: ");
builder.AppendLine().Append(indentString).Append(" Columns: ");
foreach (var column in columns)
{
builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
Expand Down
25 changes: 25 additions & 0 deletions src/EFCore.Relational/Metadata/StoreFunctionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public static string ToDebugString(

builder.Append(function.Name);

if (function.IsBuiltIn)
{
builder.Append(" IsBuiltIn");
}

if ((options & MetadataDebugStringOptions.SingleLine) == 0)
{
var parameters = function.Parameters.ToList();
Expand All @@ -70,6 +75,26 @@ public static string ToDebugString(
}
}

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));
Expand Down
54 changes: 54 additions & 0 deletions src/EFCore.Relational/Metadata/TableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ public static string ToDebugString(
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();
Expand All @@ -74,6 +98,36 @@ public static string ToDebugString(
}
}

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)
{
Expand Down
8 changes: 7 additions & 1 deletion src/EFCore.Relational/Metadata/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public static string ToDebugString(

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)
{
Expand All @@ -62,7 +68,7 @@ public static string ToDebugString(
var columns = view.Columns.ToList();
if (columns.Count != 0)
{
builder.AppendLine().Append(indentString).Append(" Properties: ");
builder.AppendLine().Append(indentString).Append(" Columns: ");
foreach (var column in columns)
{
builder.AppendLine().Append(column.ToDebugString(options, indent + 4));
Expand Down
9 changes: 9 additions & 0 deletions src/EFCore/Metadata/Internal/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,15 @@ public virtual bool SkipDetectChanges
return skipDetectChanges;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual object RelationalModel
=> this["Relational:RelationalModel"];

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down