Пример #1
0
    public EntityTypeMapping(IEntityType entityType)
    {
        Name       = entityType.Name;
        TableName  = entityType.GetTableName();
        PrimaryKey = entityType.FindPrimaryKey() !.ToDebugString(MetadataDebugStringOptions.SingleLineDefault);

        Properties.AddRange(
            entityType.GetProperties()
            .Select(p => p.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));

        Indexes.AddRange(
            entityType.GetIndexes().Select(i => $"{i.Properties.Format()} {(i.IsUnique ? "Unique" : "")}"));

        FKs.AddRange(
            entityType.GetForeignKeys().Select(f => f.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));

        Navigations.AddRange(
            entityType.GetNavigations().Select(n => n.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));

        SkipNavigations.AddRange(
            entityType.GetSkipNavigations().Select(n => n.ToDebugString(MetadataDebugStringOptions.SingleLineDefault)));
    }