{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/beef-database-v5-codegen/latest.json",
  "title": "JSON Schema for Beef Database code-generation (https://github.com/Avanade/Beef).",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/Avanade/Beef/master/tools/Beef.CodeGen.Core/Schema/database.beef-5.json",
    "sourceSha256": "e79904e01bf995c3f3e078f1dacb227b68aa6da822070e2a873d8437b8d8b74b",
    "fileMatch": [
      "database.beef-5.yaml",
      "database.beef-5.yml",
      "database.beef-5.json",
      "*.database.beef-5.yaml",
      "*.database.beef-5.yml",
      "*.database.beef-5.json"
    ],
    "parsers": [
      "json",
      "yaml"
    ]
  },
  "allOf": [
    {
      "$ref": "#/$defs/CodeGeneration"
    }
  ],
  "$defs": {
    "CodeGeneration": {
      "type": "object",
      "title": "'CodeGeneration' object (database-driven)",
      "description": "The `CodeGeneration` object defines global properties that are used to drive the underlying database-driven code generation.",
      "properties": {
        "schema": {
          "type": "string",
          "title": "The name of the `Schema` where the artefacts are defined in, or should be created in, the database.",
          "description": "This is used as the default `Schema` for all child objects."
        },
        "replace": {
          "type": "boolean",
          "title": "Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated.",
          "description": "Defaults to `true`."
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the `IsDeleted` capability.",
          "description": "Defaults to `IsDeleted`."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the `TenantId` capability.",
          "description": "Defaults to `TenantId`."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the `OrgUnitId` capability.",
          "description": "Defaults to `OrgUnitId`."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the `RowVersion` capability.",
          "description": "Defaults to `RowVersion`."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the `CreatedBy` capability.",
          "description": "Defaults to `CreatedBy`."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the `CreatedDate` capability.",
          "description": "Defaults to `CreatedDate`."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the `UpdatedBy` capability.",
          "description": "Defaults to `UpdatedBy`."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the `UpdatedDate` capability.",
          "description": "Defaults to `UpdatedDate`."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the `DeletedBy` capability.",
          "description": "Defaults to `UpdatedBy`."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the `DeletedDate` capability.",
          "description": "Defaults to `UpdatedDate`."
        },
        "orgUnitJoinSql": {
          "type": "string",
          "title": "The SQL table or function that is to be used to join against for security-based `OrgUnitId` verification.",
          "description": "Defaults to `[Sec].[fnGetUserOrgUnits]()`."
        },
        "checkUserPermissionSql": {
          "type": "string",
          "title": "The SQL stored procedure that is to be used for `Permission` verification.",
          "description": "Defaults to `[Sec].[spCheckUserHasPermission]`."
        },
        "getUserPermissionSql": {
          "type": "string",
          "title": "The SQL function that is to be used for `Permission` verification.",
          "description": "Defaults to `[Sec].[fnGetUserHasPermission]`."
        },
        "aliasColumns": {
          "type": "array",
          "title": "The list of `Column` and `Alias` pairs (split by a `^` lookup character) to enable column aliasing/renaming.",
          "description": "Each alias value should be formatted as `Column` + `^` + `Alias`; e.g. `PCODE^ProductCode`.",
          "items": {
            "type": "string"
          }
        },
        "autoDotNetRename": {
          "type": "string",
          "title": "The option to automatically rename the SQL Tables and Columns for use in .NET.",
          "description": "Defaults `SnakeKebabToPascalCase` that will remove any underscores or hyphens separating each word and capitalize the first character of each; e.g. `internal-customer_id` would be renamed as `InternalCustomerId`. The `PascalCase` option will capatilize the first character only.",
          "enum": [
            "None",
            "PascalCase",
            "SnakeKebabToPascalCase"
          ]
        },
        "preprocessorDirectives": {
          "type": "boolean",
          "title": "Indicates whether to use preprocessor directives in the generated output."
        },
        "collectionType": {
          "type": "string",
          "title": "The collection type.",
          "description": "Values are `JSON` being a JSON array (preferred) or `UDT` for a User-Defined Type (legacy). Defaults to `JSON`.",
          "enum": [
            "JSON",
            "UDT"
          ]
        },
        "efModel": {
          "type": "boolean",
          "title": "Indicates whether an `Entity Framework` .NET (C#) model is to be generated for all tables.",
          "description": "This can be overridden within the `Table`(s)."
        },
        "outbox": {
          "type": "boolean",
          "title": "Indicates whether to generate the event outbox SQL and .NET artefacts.",
          "description": "Defaults to `false`."
        },
        "outboxSchema": {
          "type": "string",
          "title": "The schema name of the event outbox table.",
          "description": "Defaults to `Outbox` (literal)."
        },
        "outboxSchemaCreate": {
          "type": "boolean",
          "title": "Indicates whether to create the `OutboxSchema` within the database.",
          "description": "Defaults to `true`."
        },
        "outboxTable": {
          "type": "string",
          "title": "The name of the event outbox table.",
          "description": "Defaults to `EventOutbox` (literal)."
        },
        "outboxEnqueueStoredProcedure": {
          "type": "string",
          "title": "The stored procedure name for the event outbox enqueue.",
          "description": "Defaults to `spEventOutboxEnqueue` (literal)."
        },
        "outboxDequeueStoredProcedure": {
          "type": "string",
          "title": "The stored procedure name for the event outbox dequeue.",
          "description": "Defaults to `spEventOutboxDequeue` (literal)."
        },
        "pathBase": {
          "type": "string",
          "title": "The base path (directory) prefix for the Database-related artefacts; other `Path*` properties append to this value when they are not specifically overridden.",
          "description": "Defaults to `Company` (runtime parameter) + `.` + `AppName` (runtime parameter). For example `Beef.Demo`."
        },
        "pathDatabaseSchema": {
          "type": "string",
          "title": "The path (directory) for the Schema Database-related artefacts.",
          "description": "Defaults to `PathBase` + `.Database/Schema` (literal). For example `Beef.Demo.Database/Schema`."
        },
        "pathDatabaseMigrations": {
          "type": "string",
          "title": "The path (directory) for the Schema Database-related artefacts.",
          "description": "Defaults to `PathBase` + `.Database/Migrations` (literal). For example `Beef.Demo.Database/Migrations`."
        },
        "pathBusiness": {
          "type": "string",
          "title": "The path (directory) for the Business-related (.NET) artefacts.",
          "description": "Defaults to `PathBase` + `.Business` (literal). For example `Beef.Demo.Business`."
        },
        "orgUnitImmutable": {
          "type": "boolean",
          "title": "Indicates whether the `OrgUnitId` column is considered immutable, in that it can not be changed once set.",
          "description": "This is only applicable for stored procedures."
        },
        "namespaceBase": {
          "type": "string",
          "title": "The base Namespace (root) for the .NET artefacts.",
          "description": "Defaults to `Company` (runtime parameter) + `.` + `AppName` (runtime parameter). For example `Beef.Demo`."
        },
        "namespaceCommon": {
          "type": "string",
          "title": "The Namespace (root) for the Common-related .NET artefacts.",
          "description": "Defaults to `NamespaceBase` + `.Common` (literal). For example `Beef.Demo.Common`."
        },
        "namespaceBusiness": {
          "type": "string",
          "title": "The Namespace (root) for the Business-related .NET artefacts.",
          "description": "Defaults to `NamespaceBase` + `.Business` (literal). For example `Beef.Demo.Business`."
        },
        "namespaceOutbox": {
          "type": "string",
          "title": "The Namespace (root) for the Outbox-related Publisher .NET artefacts.",
          "description": "Defaults to `NamespaceBusiness`."
        },
        "tables": {
          "type": "array",
          "title": "The corresponding `Table` collection.",
          "items": {
            "$ref": "#/$defs/Table"
          }
        },
        "queries": {
          "type": "array",
          "title": "The corresponding `Query` collection.",
          "items": {
            "$ref": "#/$defs/Query"
          }
        }
      }
    },
    "Table": {
      "type": "object",
      "title": "'Table' object (entity-driven)",
      "description": "The `Table` object identifies an existing database `Table` (or `View`) and defines its code-generation characteristics.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the `Table` in the database."
        },
        "schema": {
          "type": "string",
          "title": "The name of the `Schema` where the `Table` is defined in the database.",
          "description": "Defaults to `CodeGeneration.Schema`."
        },
        "alias": {
          "type": "string",
          "title": "The `Schema.Table` alias name.",
          "description": "Will automatically default where not specified."
        },
        "replace": {
          "type": "boolean",
          "title": "Indicates whether the existing database object should be replaced/altered or whether the object is dropped and recreated.",
          "description": "Defaults to `CodeGeneration.Replace`."
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be included in the underlying generated output.",
          "description": "Where not specified this indicates that all `Columns` are to be included.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be excluded from the underlying generated output.",
          "description": "Where not specified this indicates no `Columns` are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "aliasColumns": {
          "type": "array",
          "title": "The list of `Column` and `Alias` pairs (split by a `^` lookup character) to enable column aliasing/renaming.",
          "description": "Each alias value should be formatted as `Column` + `^` + `Alias`; e.g. `PCODE^ProductCode`.",
          "items": {
            "type": "string"
          }
        },
        "jsonAliasColumns": {
          "type": "array",
          "title": "The list of JSON `Column` and `JsonAlias` pairs (split by a `^` lookup character) to enable column aliasing/renaming.",
          "description": "Each alias value should be formatted as `Column` + `^` + `Alias`; e.g. `ProductCode^product`.",
          "items": {
            "type": "string"
          }
        },
        "get": {
          "type": "boolean",
          "title": "Indicates whether a `Get` stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "getAll": {
          "type": "boolean",
          "title": "Indicates whether a `GetAll` stored procedure is to be automatically generated where not otherwise explicitly specified.",
          "description": "The `GetAllOrderBy` is used to specify the `GetAll` query sort order."
        },
        "getAllOrderBy": {
          "type": "array",
          "title": "The list of `Column` names (including sort order `ASC`/`DESC` literal) to be used as the `GetAll` query sort order.",
          "description": "This relates to the `GetAll` selection.",
          "items": {
            "type": "string"
          }
        },
        "create": {
          "type": "boolean",
          "title": "Indicates whether a `Create` stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "update": {
          "type": "boolean",
          "title": "Indicates whether a `Update` stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "upsert": {
          "type": "boolean",
          "title": "Indicates whether a `Upsert` stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "delete": {
          "type": "boolean",
          "title": "Indicates whether a `Delete` stored procedure is to be automatically generated where not otherwise explicitly specified."
        },
        "merge": {
          "type": "boolean",
          "title": "Indicates whether a `Merge` (insert/update/delete of `Udt` list) stored procedure is to be automatically generated where not otherwise explicitly specified.",
          "description": "This will also require a `Udt` (SQL User Defined Table) and `Tvp` (.NET Table-Valued Parameter) to function."
        },
        "efModel": {
          "type": "boolean",
          "title": "Indicates whether an `Entity Framework` .NET (C#) model is to be generated.",
          "description": "Defaults to `CodeGeneration.EfModel`."
        },
        "efModelName": {
          "type": "string",
          "title": "The .NET (C#) EntityFramework (EF) model name.",
          "description": "Defaults to `Name` applying the `CodeGeneration.AutoDotNetRename`."
        },
        "udt": {
          "type": "boolean",
          "title": "Indicates whether a `User Defined Table (UDT)` type should be created."
        },
        "udtExcludeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be excluded from the `User Defined Table (UDT)`.",
          "description": "Where not specified this indicates that no `Columns` are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "tvp": {
          "type": "string",
          "title": "The name of the .NET entity associated with the `Udt` so that it can be expressed (created) as a Table-Valued Parameter for usage within the corresponding `DbMapper`."
        },
        "collectionType": {
          "type": "string",
          "title": "The collection type.",
          "description": "Values are `JSON` being a JSON array (preferred) or `UDT` for a User-Defined Type (legacy). Defaults to `Config.CollectionType`.",
          "enum": [
            "JSON",
            "UDT"
          ]
        },
        "permission": {
          "type": "string",
          "title": "The permission (prefix) to be used for security permission checking (suffix defaults to `Read`, `Write` or `Delete` and can be overridden in the underlying stored procedure)."
        },
        "orgUnitImmutable": {
          "type": "boolean",
          "title": "Indicates whether the `OrgUnitId` column is considered immutable, in that it can not be changed once set.",
          "description": "Defaults to `CodeGeneration.OrgUnitImmutable`. This is only applicable for stored procedures."
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the `IsDeleted` capability.",
          "description": "Defaults to `CodeGeneration.IsDeleted`."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the `TenantId` capability.",
          "description": "Defaults to `CodeGeneration.TenantId`."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the `OrgUnitId` capability.",
          "description": "Defaults to `CodeGeneration.OrgUnitId`."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the `RowVersion` capability.",
          "description": "Defaults to `CodeGeneration.RowVersion`."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the `CreatedBy` capability.",
          "description": "Defaults to `CodeGeneration.CreatedBy`."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the `CreatedDate` capability.",
          "description": "Defaults to `CodeGeneration.CreatedDate`."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the `UpdatedBy` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedBy`."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the `UpdatedDate` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedDate`."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the `DeletedBy` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedBy`."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the `DeletedDate` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedDate`."
        },
        "storedProcedures": {
          "type": "array",
          "title": "The corresponding `StoredProcedure` collection.",
          "items": {
            "$ref": "#/$defs/StoredProcedure"
          }
        },
        "relationships": {
          "type": "array",
          "title": "The corresponding Entity Frameworrk (EF) `Relationship` collection.",
          "items": {
            "$ref": "#/$defs/Relationship"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "StoredProcedure": {
      "type": "object",
      "title": "'StoredProcedure' object (database-driven)",
      "description": "The code generation for an `StoredProcedure` is primarily driven by the `Type` property. This encourages (enforces) a consistent implementation for the standardised **CRUD** (Create, Read, Update and Delete) actions, as well as supporting `Upsert`, `Merge` and ad-hoc queries as required.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the `StoredProcedure`; generally the verb/action, i.e. `Get`, `Update`, etc.",
          "description": "See `StoredProcedureName` for the actual name used in the database."
        },
        "type": {
          "type": "string",
          "title": "The stored procedure operation type.",
          "description": "Defaults to `GetColl`.",
          "enum": [
            "Get",
            "GetColl",
            "Create",
            "Update",
            "Upsert",
            "Delete",
            "Merge"
          ]
        },
        "paging": {
          "type": "boolean",
          "title": "Indicates whether standardized paging support should be added.",
          "description": "This only applies where the stored procedure operation `Type` is `GetColl`."
        },
        "storedProcedureName": {
          "type": "string",
          "title": "The `StoredProcedure` name in the database.",
          "description": "Defaults to `sp` + `Table.Name` + `Name`; e.g. `spTableName` or `spPersonGet`."
        },
        "replace": {
          "type": "boolean",
          "title": "Indicates whether the existing `StoredProcedure` database object should be replaced/altered or whether the object is dropped and recreated.",
          "description": "Defaults to `CodeGeneration.Replace`."
        },
        "reselectStatement": {
          "type": "string",
          "title": "The SQL statement to perform the reselect after a `Create`, `Update` or `Upsert` stored procedure operation `Type`.",
          "description": "Defaults to `[{{Table.Schema}}].[sp{{Table.Name}}Get]` passing the primary key column(s)."
        },
        "intoTempTable": {
          "type": "boolean",
          "title": "Indicates whether to select into a `#TempTable` to allow other statements access to the selected data.",
          "description": "A `Select * from #TempTable` is also performed (code-generated) where the stored procedure operation `Type` is `GetColl`."
        },
        "withHints": {
          "type": "string",
          "title": "the table hints using the SQL Server `WITH()` statement; the value specified will be used as-is; e.g. `NOLOCK` will result in `WITH(NOLOCK)`."
        },
        "collectionType": {
          "type": "string",
          "title": "The collection type.",
          "description": "Values are `JSON` being a JSON array (preferred) or `UDT` for a User-Defined Type (legacy). Defaults to `Table.CollectionType`.",
          "enum": [
            "JSON",
            "UDT"
          ]
        },
        "mergeOverrideIdentityColumns": {
          "type": "array",
          "title": "The list of `Column` names to be used in the `Merge` statement to determine whether to _insert_, _update_ or _delete_.",
          "description": "This is used to override the default behaviour of using the primary key column(s).",
          "items": {
            "type": "string"
          }
        },
        "permission": {
          "type": "string",
          "title": "The name of the `StoredProcedure` in the database."
        },
        "orgUnitImmutable": {
          "type": "boolean",
          "title": "Indicates whether the `OrgUnitId` column is considered immutable, in that it can not be changed once set.",
          "description": "Defaults to `Table.OrgUnitImmutable`."
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be included in the underlying generated _settable_ output (further filters `Table.IncludeColumns`).",
          "description": "Where not specified this indicates that all `Columns` are to be included. Only filters the columns where `Type` is `Get`, `GetColl`, `Create`, `Update` or `Upsert`.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be excluded from the underlying generated _settable_ output (further filters `Table.ExcludeColumns`).",
          "description": "Where not specified this indicates no `Columns` are to be excluded. Only filters the columns where `Type` is `Get`, `GetColl`, `Create`, `Update` or `Upsert`.",
          "items": {
            "type": "string"
          }
        },
        "parameters": {
          "type": "array",
          "title": "The corresponding `Parameter` collection.",
          "items": {
            "$ref": "#/$defs/Parameter"
          }
        },
        "where": {
          "type": "array",
          "title": "The corresponding `Where` collection.",
          "items": {
            "$ref": "#/$defs/Where"
          }
        },
        "orderby": {
          "type": "array",
          "title": "The corresponding `OrderBy` collection.",
          "items": {
            "$ref": "#/$defs/OrderBy"
          }
        },
        "execute": {
          "type": "array",
          "title": "The corresponding `Execute` collection.",
          "items": {
            "$ref": "#/$defs/Execute"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "Parameter": {
      "type": "object",
      "title": "'Parameter' object (database-driven)",
      "description": "The `Parameter` is used to define a stored procedure parameter and its charateristics. These are in addition to those that are automatically inferred (added) by the selected `StoredProcedure.Type`.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The parameter name (without the `@` prefix)."
        },
        "column": {
          "type": "string",
          "title": "The corresponding column name; used to infer characteristics.",
          "description": "Defaults to `Name`."
        },
        "sqlType": {
          "type": "string",
          "title": "The SQL type definition (overrides inherited Column definition) including length/precision/scale."
        },
        "nullable": {
          "type": "boolean",
          "title": "Indicates whether the parameter is nullable.",
          "description": "Note that when the parameter value is `NULL` it will not be included in the query."
        },
        "treatColumnNullAs": {
          "type": "boolean",
          "title": "Indicates whether the column value where NULL should be treated as the specified value; results in: `ISNULL([x].[col], value)`."
        },
        "collection": {
          "type": "boolean",
          "title": "Indicates whether the parameter is a collection (one or more values to be included `IN` the query)."
        },
        "collectionType": {
          "type": "string",
          "title": "The collection type.",
          "description": "Values are `JSON` being a JSON array (preferred) or `UDT` for a User-Defined Type (legacy). Defaults to `StoredProcedure.CollectionType`.",
          "enum": [
            "JSON",
            "UDT"
          ]
        },
        "operator": {
          "type": "string",
          "title": "The where clause equality operator",
          "description": "Defaults to `EQ`.",
          "enum": [
            "EQ",
            "NE",
            "LT",
            "LE",
            "GT",
            "GE",
            "LIKE"
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "Where": {
      "type": "object",
      "title": "'Where' object (database-driven)",
      "description": "The `Where` object defines an additional where `Statement` to be added. This is in addition to those automatically added based on the `StoredProcedure.Type`.",
      "properties": {
        "statement": {
          "type": "string",
          "title": "The where statement (TSQL)."
        }
      },
      "required": [
        "statement"
      ]
    },
    "OrderBy": {
      "type": "object",
      "title": "'OrderBy' object (database-driven)",
      "description": "The `OrderBy` object defines the query order. Only valid for `StoredProcedure.Type` of `GetAll`.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the `Column` to order by."
        },
        "order": {
          "type": "string",
          "title": "The corresponding sort order.",
          "description": "Defaults to `Ascending`.",
          "enum": [
            "Ascending",
            "Descending"
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "Execute": {
      "type": "object",
      "title": "'Execute' object (database-driven)",
      "description": "The _Execute_ object enables additional TSQL statements to be embedded within the stored procedure.",
      "properties": {
        "statement": {
          "type": "string",
          "title": "The additional TSQL statement."
        },
        "location": {
          "type": "string",
          "title": "The location of the statement in relation to the underlying primary stored procedure statement.",
          "description": "Defaults to `After`.",
          "enum": [
            "Before",
            "After"
          ]
        }
      },
      "required": [
        "statement"
      ]
    },
    "Relationship": {
      "type": "object",
      "title": "'Relationship' object (database-driven)",
      "description": "The `Relationship` object enables the definition of an entity framework (EF) model relationship.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the primary table of the query."
        },
        "schema": {
          "type": "string",
          "title": "The schema name of the primary table of the view.",
          "description": "Defaults to `CodeGeneration.Schema`."
        },
        "type": {
          "type": "string",
          "title": "The relationship type between the parent and child (self).",
          "description": "Defaults to `OneToMany`.",
          "enum": [
            "OneToMany",
            "ManyToOne"
          ]
        },
        "foreignKeyColumns": {
          "type": "array",
          "title": "The list of `Column` names from the related table that reference the parent.",
          "items": {
            "type": "string"
          }
        },
        "principalKeyColumns": {
          "type": "array",
          "title": "The list of `Column` names from the principal table that reference the child.",
          "description": " Typically this is only used where referencing property(s) other than the primary key as the principal property(s).",
          "items": {
            "type": "string"
          }
        },
        "onDelete": {
          "type": "string",
          "title": "The operation applied to dependent entities in the relationship when the principal is deleted or the relationship is severed.",
          "description": "Defaults to `NoAction`. See <https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.deletebehavior> for more information.",
          "enum": [
            "NoAction",
            "Cascade",
            "ClientCascade",
            "ClientNoAction",
            "ClientSetNull",
            "Restrict",
            "SetNull"
          ]
        },
        "autoInclude": {
          "type": "boolean",
          "title": "Indicates whether to automatically include navigation to the property.",
          "description": "Defaults to `false`."
        },
        "propertyName": {
          "type": "string",
          "title": "The corresponding property name within the entity framework (EF) model.",
          "description": "Defaults to `Name` using the `CodeGeneration.AutoDotNetRename` option."
        },
        "efModelName": {
          "type": "string",
          "title": "The corresponding entity framework (EF) model name (.NET Type).",
          "description": "Defaults to `Name` using the `CodeGeneration.AutoDotNetRename` option."
        }
      },
      "required": [
        "name"
      ]
    },
    "Query": {
      "type": "object",
      "title": "'Query' object (database-driven)",
      "description": "The `Query` object enables the definition of more complex multi-table queries (`Joins`) that would primarily result in a database _View_. The primary table `Name` for the query is required to be specified. Multiple queries can be specified for the same table(s). The `IncludeColumns` and `ExcludeColumns` provide a shorthand to include or exclude selected columns; with the `AliasColumns` providing a means to rename where required (for example duplicate name). Additional `Where` and `Order` configuration can also be added as required.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the primary table of the query."
        },
        "schema": {
          "type": "string",
          "title": "The schema name of the primary table of the view.",
          "description": "Defaults to `CodeGeneration.Schema`."
        },
        "alias": {
          "type": "string",
          "title": "The `Schema.Table` alias name.",
          "description": "Will automatically default where not specified."
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be included in the underlying generated output.",
          "description": "Where not specified this indicates that all `Columns` are to be included.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be excluded from the underlying generated output.",
          "description": "Where not specified this indicates no `Columns` are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "aliasColumns": {
          "type": "array",
          "title": "The list of `Column` and `Alias` pairs (split by a `^` lookup character) to enable column aliasing/renaming.",
          "description": "Each alias value should be formatted as `Column` + `^` + `Alias`; e.g. `PCODE^ProductCode`",
          "items": {
            "type": "string"
          }
        },
        "view": {
          "type": "boolean",
          "title": "Indicates whether a `View` is to be generated."
        },
        "viewName": {
          "type": "string",
          "title": "The `View` name.",
          "description": "Defaults to `vw` + `Name`; e.g. `vwTableName`."
        },
        "viewSchema": {
          "type": "string",
          "title": "The schema name for the `View`.",
          "description": "Defaults to `Schema`."
        },
        "viewReplace": {
          "type": "boolean",
          "title": "Indicates whether the existing `View` database object should be replaced/altered or whether the object is dropped and recreated.",
          "description": "Defaults to `CodeGeneration.Replace`."
        },
        "permission": {
          "type": "string",
          "title": "The permission to be used for security permission checking.",
          "description": "The suffix is optional, and where not specified will default to `.READ`."
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the `IsDeleted` capability.",
          "description": "Defaults to `CodeGeneration.IsDeleted`."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the `TenantId` capability.",
          "description": "Defaults to `CodeGeneration.TenantId`."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the `OrgUnitId` capability.",
          "description": "Defaults to `CodeGeneration.OrgUnitId`."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the `RowVersion` capability.",
          "description": "Defaults to `CodeGeneration.RowVersion`."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the `CreatedBy` capability.",
          "description": "Defaults to `CodeGeneration.CreatedBy`."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the `CreatedDate` capability.",
          "description": "Defaults to `CodeGeneration.CreatedDate`."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the `UpdatedBy` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedBy`."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the `UpdatedDate` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedDate`."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the `DeletedBy` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedBy`."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the `DeletedDate` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedDate`."
        },
        "joins": {
          "type": "array",
          "title": "The corresponding `Join` collection.",
          "items": {
            "$ref": "#/$defs/QueryJoin"
          }
        },
        "order": {
          "type": "array",
          "title": "The corresponding `Order` collection.",
          "items": {
            "$ref": "#/$defs/QueryOrder"
          }
        },
        "where": {
          "type": "array",
          "title": "The corresponding `Where` collection.",
          "items": {
            "$ref": "#/$defs/QueryWhere"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryJoin": {
      "type": "object",
      "title": "'QueryJoin' object (database-driven)",
      "description": "The `QueryJoin` object defines a join to another (or same) table within a query. The `Type` defines the join type, such as inner join, etc. The `IncludeColumns` and `ExcludeColumns` provide a shorthand to include or exclude selected columns; with the `AliasColumns` providing a means to rename where required (for example duplicate name).",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the table to join."
        },
        "schema": {
          "type": "string",
          "title": "The schema name of the table to join.",
          "description": "Defaults to `Table.Schema`; i.e. same schema."
        },
        "alias": {
          "type": "string",
          "title": "The `Schema.Table` alias name.",
          "description": "Will automatically default where not specified."
        },
        "type": {
          "type": "string",
          "title": "The SQL join type.",
          "description": "Defaults to `Inner`.",
          "enum": [
            "Inner",
            "Left",
            "Right",
            "Full"
          ]
        },
        "includeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be included in the underlying generated output.",
          "description": "Where not specified this indicates that all `Columns` are to be included.",
          "items": {
            "type": "string"
          }
        },
        "excludeColumns": {
          "type": "array",
          "title": "The list of `Column` names to be excluded from the underlying generated output.",
          "description": "Where not specified this indicates no `Columns` are to be excluded.",
          "items": {
            "type": "string"
          }
        },
        "aliasColumns": {
          "type": "array",
          "title": "The list of `Column` and `Alias` pairs (split by a `^` lookup character) to enable column renaming.",
          "description": "Each alias value should be formatted as `Column` + `^` + `Alias`; e.g. `PCODE^ProductCode`",
          "items": {
            "type": "string"
          }
        },
        "columnNameIsDeleted": {
          "type": "string",
          "title": "The column name for the `IsDeleted` capability.",
          "description": "Defaults to `CodeGeneration.IsDeleted`."
        },
        "columnNameTenantId": {
          "type": "string",
          "title": "The column name for the `TenantId` capability.",
          "description": "Defaults to `CodeGeneration.TenantId`."
        },
        "columnNameOrgUnitId": {
          "type": "string",
          "title": "The column name for the `OrgUnitId` capability.",
          "description": "Defaults to `CodeGeneration.OrgUnitId`."
        },
        "columnNameRowVersion": {
          "type": "string",
          "title": "The column name for the `RowVersion` capability.",
          "description": "Defaults to `CodeGeneration.RowVersion`."
        },
        "columnNameCreatedBy": {
          "type": "string",
          "title": "The column name for the `CreatedBy` capability.",
          "description": "Defaults to `CodeGeneration.CreatedBy`."
        },
        "columnNameCreatedDate": {
          "type": "string",
          "title": "The column name for the `CreatedDate` capability.",
          "description": "Defaults to `CodeGeneration.CreatedDate`."
        },
        "columnNameUpdatedBy": {
          "type": "string",
          "title": "The column name for the `UpdatedBy` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedBy`."
        },
        "columnNameUpdatedDate": {
          "type": "string",
          "title": "The column name for the `UpdatedDate` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedDate`."
        },
        "columnNameDeletedBy": {
          "type": "string",
          "title": "The column name for the `DeletedBy` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedBy`."
        },
        "columnNameDeletedDate": {
          "type": "string",
          "title": "The column name for the `DeletedDate` capability.",
          "description": "Defaults to `CodeGeneration.UpdatedDate`."
        },
        "on": {
          "type": "array",
          "title": "The corresponding `JoinOn` collection.",
          "items": {
            "$ref": "#/$defs/QueryJoinOn"
          }
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryJoinOn": {
      "type": "object",
      "title": "'QueryJoinOn' object (database-driven)",
      "description": "The `QueryJoinOn` object defines the join on characteristics for a join within a query.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the join column (from the `Join` table)."
        },
        "toSchema": {
          "type": "string",
          "title": "The name of the other join to table schema.",
          "description": "Defaults to `Table.Schema`; i.e. same schema. See also `ToTable` and `ToColumn` as these all relate."
        },
        "toTable": {
          "type": "string",
          "title": "The name of the other join to table.",
          "description": "Defaults to `Table.Name`; i.e. primary table. See also `ToSchema` and `ToColumn` as these all relate."
        },
        "toColumn": {
          "type": "string",
          "title": "The name of the other join to column.",
          "description": "Defaults to `Name`; i.e. assumes same name. See also `ToSchema` and `ToTable` as these all relate."
        },
        "toStatement": {
          "type": "string",
          "title": "The fully qualified name (`Alias.Name`) of the other column being joined to or other valid SQL (e.g. function) bypassing the corresponding `Schema`, `Table` and `Column` logic."
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryOrder": {
      "type": "object",
      "title": "'QueryOrder' object (database-driven)",
      "description": "The `QueryOrder` object that defines the query order.",
      "properties": {
        "name": {
          "type": "string",
          "title": "The name of the `Column` to order by.",
          "description": "See also `Schema` and `Table` as these all relate."
        },
        "schema": {
          "type": "string",
          "title": "The name of order by table schema. See also `Name` and `Column` as these all relate.",
          "description": "Defaults to `Query.Schema`."
        },
        "table": {
          "type": "string",
          "title": "The name of the order by table.",
          "description": "Defaults to `Table.Name`; i.e. primary table. See also `Schema` and `Column` as these all relate."
        },
        "order": {
          "type": "string",
          "title": "The corresponding sort order.",
          "description": "Defaults to `Ascending`.",
          "enum": [
            "Ascending",
            "Descending"
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "QueryWhere": {
      "type": "object",
      "title": "'QueryWhere' object (database-driven)",
      "description": "The `QueryWhere` object defines an additional where `Statement` to be added.",
      "properties": {
        "statement": {
          "type": "string",
          "title": "The where TSQL statement."
        }
      },
      "required": [
        "statement"
      ]
    }
  }
}
