/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static string ToDebugString([NotNull] this IProperty property, bool singleLine = true, [NotNull] string indent = "") { var builder = new StringBuilder(); builder.Append(indent); if (singleLine) { builder.Append("Property: ").Append(property.DeclaringEntityType.DisplayName()).Append("."); } builder.Append(property.Name).Append(" ("); var field = property.GetFieldName(); if (field == null) { builder.Append("no field, "); } else if (!field.EndsWith(">k__BackingField", StringComparison.Ordinal)) { builder.Append(field).Append(", "); } builder.Append(property.ClrType.ShortDisplayName()).Append(")"); if (property.IsShadowProperty) { builder.Append(" Shadow"); } if (property.IsIndexedProperty) { builder.Append(" Indexed"); } if (!property.IsNullable) { builder.Append(" Required"); } if (property.IsPrimaryKey()) { builder.Append(" PK"); } if (property.IsForeignKey()) { builder.Append(" FK"); } if (property.IsKey() && !property.IsPrimaryKey()) { builder.Append(" AlternateKey"); } if (property.IsIndex()) { builder.Append(" Index"); } if (property.IsConcurrencyToken) { builder.Append(" Concurrency"); } if (property.BeforeSaveBehavior != PropertySaveBehavior.Save) { builder.Append(" BeforeSave:").Append(property.BeforeSaveBehavior); } if (property.AfterSaveBehavior != PropertySaveBehavior.Save) { builder.Append(" AfterSave:").Append(property.AfterSaveBehavior); } if (property.ValueGenerated != ValueGenerated.Never) { builder.Append(" ValueGenerated.").Append(property.ValueGenerated); } if (property.GetMaxLength() != null) { builder.Append(" MaxLength").Append(property.GetMaxLength()); } if (property.IsUnicode() == false) { builder.Append(" Ansi"); } if (property.GetPropertyAccessMode() != PropertyAccessMode.PreferField) { builder.Append(" PropertyAccessMode.").Append(property.GetPropertyAccessMode()); } var indexes = property.GetPropertyIndexes(); builder.Append(" ").Append(indexes.Index); builder.Append(" ").Append(indexes.OriginalValueIndex); builder.Append(" ").Append(indexes.RelationshipIndex); builder.Append(" ").Append(indexes.ShadowIndex); builder.Append(" ").Append(indexes.StoreGenerationIndex); if (!singleLine) { builder.Append(property.AnnotationsToDebugString(indent + " ")); } return(builder.ToString()); }