private void CreateViews(StringBuilder sql, IEnumerable <LookupData> enums)
        {
            string schemaWithBrackets    = GetSchema("[", "].");
            string schema                = GetSchema();
            string descriptionDefinition = GenerateDescription ? ", CAST(Description as nvarchar(max)) as Description" : null;
            string description           = GenerateDescription ? ", Description" : null;

            string appendTuppleDelimiter = ", ";
            string appendDelimiter       = Environment.NewLine + "\t\t\t";
            string appendSelectDelimiter = "UNION" + appendDelimiter;

            Action <StringBuilder, LookupValue> appendTupleValue  = GenerateDescription ? (Action <StringBuilder, LookupValue>)AppendValueTupleWithDescription : AppendValueTuple;
            Action <StringBuilder, LookupValue> appendSelectValue = GenerateDescription ? (Action <StringBuilder, LookupValue>)AppendSelectValueWithDescription : AppendSelectValues;

            foreach (LookupData lookup in enums)
            {
                string tableName          = TableName(lookup.Name);
                string schemaAndTableName = TableName(lookup.Name, true);
                string idType             = SqlServerGenerationHelper.NumericSqlType(lookup.NumericType);

                sql.AppendLine($"IF (OBJECT_ID('{schemaAndTableName}', 'V') IS NOT NULL) EXEC ('DROP VIEW {schemaWithBrackets}[{tableName}]')");
                sql.AppendLine($"EXEC ('CREATE VIEW {schemaWithBrackets}[{tableName}] AS");
                sql.AppendLine($"\tSELECT CAST(Id as {idType}) as Id, CAST(Name as nvarchar({NameFieldLength:0})) as Name{descriptionDefinition}");
                sql.AppendLine("\tFROM (");

                if (lookup.Values.Count <= 1000)
                {
                    sql.AppendLine("\t\tVALUES");
                    ForEarchLookupValue(lookup, sql, appendDelimiter, appendTuppleDelimiter, appendTupleValue);
                }
                else
                {
                    ForEarchLookupValue(lookup, sql, appendDelimiter, appendSelectDelimiter, appendSelectValue);
                }

                sql.AppendLine();
                sql.AppendLine($"\t) as t(Id,Name{description})");
                sql.AppendLine("');");

                sql.AppendViewMetadataDescriptionLine(schema, tableName, DbObjectDescription);
            }
        }
        private string CreateTables(IEnumerable <LookupData> enums)
        {
            StringBuilder sql = new StringBuilder();

            string schema             = GetSchema();
            string schemaWithBrackets = GetSchema("[", "].");

            string description = GenerateDescription ? ", Description nvarchar(max)" : null;

            foreach (LookupData lookup in enums)
            {
                string tableName          = TableName(lookup.Name);
                string schemaAndTableName = TableName(lookup.Name, true);
                string idType             = SqlServerGenerationHelper.NumericSqlType(lookup.NumericType);

                sql.AppendLine($"IF OBJECT_ID('{schemaAndTableName}', 'U') IS NULL");
                sql.AppendLine("begin");
                sql.AppendLine($"\tCREATE TABLE {schemaWithBrackets}[{tableName}] (Id {idType} CONSTRAINT PK_{tableName} PRIMARY KEY, Name nvarchar({NameFieldLength:0}){description})");

                sql.AppendTableMetadataDescriptionLine(schema, tableName, DbObjectDescription, "\t");
                sql.AppendLine("end");
            }
            return(sql.ToString());
        }