/// <summary>
        /// Applies project settings to fields name
        /// </summary>
        private string NaturalizeNames_ForeignTableFieldName(DbTable table, DbForeignKey foreignKey)
        {
            if (string.IsNullOrEmpty(foreignKey.ForeignTableNameInLocalTable))
            {
                return(foreignKey.ForeignTableNameInLocalTable);
            }
            var newName = NaturalizeNames_TableName_Rename(foreignKey.ForeignTableNameInLocalTable);

            var stringCompare = StringComparison.InvariantCulture;

            if (_patternProject.LanguageSettings.KeywordsCaseSensitive == false)
            {
                stringCompare = StringComparison.InvariantCultureIgnoreCase;
            }

            // suppress pattern
            string replacement = _patternProject.LanguageSettings.LanguageKeywordsSuppress;

            int    initReplacePartCount = 0;
            string initReplacePartStr   = "";

            // column name should not be the same
            if (newName.Equals(table.TableNameSchema, stringCompare) ||
                newName.Equals(table.TableNameSchemaCS, stringCompare))
            {
                var renamedName = string.Format(replacement, newName, initReplacePartStr);
                initReplacePartCount++;
                initReplacePartStr = initReplacePartCount.ToString();

                // no duplicate
                while (table.FindColumnSchema(renamedName) != null ||
                       table.ForeignKeys.Any(x => x.ForeignTableNameInLocalTable.Equals(renamedName, stringCompare)))
                {
                    renamedName = string.Format(replacement, newName, initReplacePartStr);
                    initReplacePartCount++;
                    initReplacePartStr = initReplacePartCount.ToString();
                }
                newName = renamedName;
            }

            // foreign name is not changed and is a member
            if (newName.Equals(foreignKey.ForeignTableNameInLocalTable, stringCompare))
            {
                var sameNameForeignKeys =
                    table.ForeignKeys.Where(x => x.ForeignTableNameInLocalTable.Equals(newName, stringCompare)).ToList();

                // no more than one occurrence, including itself
                if (table.FindColumnSchema(newName) != null ||
                    (sameNameForeignKeys.Count > 1 && sameNameForeignKeys.IndexOf(foreignKey) > 0))
                {
                    var renamedName = string.Format(replacement, newName, initReplacePartStr);
                    initReplacePartCount++;
                    initReplacePartStr = initReplacePartCount.ToString();

                    // no duplicate
                    while (table.FindColumnSchema(renamedName) != null ||
                           table.ForeignKeys.Any(x => x.ForeignTableNameInLocalTable.Equals(renamedName, stringCompare)))
                    {
                        renamedName = string.Format(replacement, newName, initReplacePartStr);
                        initReplacePartCount++;
                        initReplacePartStr = initReplacePartCount.ToString();
                    }
                    newName = renamedName;
                }
            }
            else
            {
                if (table.FindColumnSchema(newName) != null ||
                    table.ForeignKeys.Any(x => x.ForeignTableNameInLocalTable.Equals(newName, stringCompare)))
                {
                    var renamedName = string.Format(replacement, newName, initReplacePartStr);
                    initReplacePartCount++;
                    initReplacePartStr = initReplacePartCount.ToString();

                    // no duplicate
                    while (table.FindColumnSchema(renamedName) != null ||
                           table.ForeignKeys.Any(x => x.ForeignTableNameInLocalTable.Equals(renamedName, stringCompare)))
                    {
                        renamedName = string.Format(replacement, newName, initReplacePartStr);
                        initReplacePartCount++;
                        initReplacePartStr = initReplacePartCount.ToString();
                    }
                    newName = renamedName;
                }
            }

            // checking keyword match if only foreign name is not changed
            if (newName.Equals(foreignKey.ForeignTableNameInLocalTable, stringCompare))
            {
                // ignoring keywords
                foreach (var keyword in _patternProject.LanguageSettings.LanguageKeywords)
                {
                    // keyword match
                    if (newName.Equals(keyword, stringCompare))
                    {
                        var renamedName = string.Format(replacement, newName, initReplacePartStr);
                        initReplacePartCount++;
                        initReplacePartStr = initReplacePartCount.ToString();

                        // no duplicate
                        while (table.FindColumnSchema(renamedName) != null ||
                               table.ForeignKeys.Any(x => x.ForeignTableNameInLocalTable.Equals(renamedName, stringCompare)))
                        {
                            renamedName = string.Format(replacement, newName, initReplacePartStr);
                            initReplacePartCount++;
                            initReplacePartStr = initReplacePartCount.ToString();
                        }

                        newName = renamedName;
                        // name is chaned and check is no longer required
                        break;
                    }
                }
            }

            // foreign name is ok to be used
            return(newName);
        }
        ///// <summary>
        ///// Applies project settings to .NET data type
        ///// </summary>
        //private string NaturalizeNames_DotNetType(string dotNetTypeName)
        //{
        //    return dotNetTypeName.Replace(DbColumn.DotNetArrayIdenticator, _patternProject.LanguageSettings.ArrayIdenticator);
        //}

        /// <summary>
        /// Applies project settings to fields name
        /// </summary>
        /// <param name="table"></param>
        /// <param name="fieldName"></param>
        /// <param name="isAlreadyMember">is the field aready member of the table, or it is an external</param>
        /// <returns></returns>
        private string NaturalizeNames_FieldName(DbTable table, DbColumn column, string fieldName, bool isAlreadyMember)
        {
            if (string.IsNullOrEmpty(fieldName))
            {
                return(fieldName);
            }
            var newName = fieldName;

            var stringCompare = StringComparison.InvariantCulture;

            if (_patternProject.LanguageSettings.KeywordsCaseSensitive == false)
            {
                stringCompare = StringComparison.InvariantCultureIgnoreCase;
            }

            // suppress pattern
            string replacement = _patternProject.LanguageSettings.LanguageKeywordsSuppress;

            // renaming options
            newName = NaturalizeNames_RenamingOptions(newName, _projectDef.RenamingOptions, false, true);

            // remove names
            newName = NaturalizeNames_Name_RemoveInvalidChars(newName);

            int    initReplacePartCount = 0;
            string initReplacePartStr   = "";

            // column name should not be same
            if (newName.Equals(table.TableNameSchema, stringCompare) ||
                newName.Equals(table.TableNameSchemaCS, stringCompare))
            {
                var renamedName = string.Format(replacement, newName, initReplacePartStr);
                initReplacePartCount++;
                initReplacePartStr = initReplacePartCount.ToString();

                // no duplicate
                while (table.FindColumnSchema(renamedName) != null)
                {
                    renamedName = string.Format(replacement, newName, initReplacePartStr);
                    initReplacePartCount++;
                    initReplacePartStr = initReplacePartCount.ToString();
                }

                newName = renamedName;
            }

            // field name is not changed and is a member
            if (newName.Equals(fieldName, stringCompare) && isAlreadyMember)
            {
                var sameNameColumns =
                    table.SchemaColumns.Where(x => x.FieldNameSchema.Equals(newName, stringCompare)).ToList();

                // no more than one accurance, including itself
                if (sameNameColumns.Count > 1 &&
                    sameNameColumns.IndexOf(column) > 0)
                {
                    var renamedName = string.Format(replacement, newName, initReplacePartStr);
                    initReplacePartCount++;
                    initReplacePartStr = initReplacePartCount.ToString();

                    // no duplicate
                    while (table.FindColumnSchema(renamedName) != null)
                    {
                        renamedName = string.Format(replacement, newName, initReplacePartStr);
                        initReplacePartCount++;
                        initReplacePartStr = initReplacePartCount.ToString();
                    }
                    newName = renamedName;
                }
            }
            else
            {
                if (table.FindColumnSchema(newName) != null)
                {
                    var renamedName = string.Format(replacement, newName, initReplacePartStr);
                    initReplacePartCount++;
                    initReplacePartStr = initReplacePartCount.ToString();

                    // no duplicate
                    while (table.FindColumnSchema(renamedName) != null)
                    {
                        renamedName = string.Format(replacement, newName, initReplacePartStr);
                        initReplacePartCount++;
                        initReplacePartStr = initReplacePartCount.ToString();
                    }
                    newName = renamedName;
                }
            }

            // checking keyword match if only not changed field name
            if (newName.Equals(fieldName, stringCompare))
            {
                // ignoring keywords
                foreach (var keyword in _patternProject.LanguageSettings.LanguageKeywords)
                {
                    // keyword match
                    if (newName.Equals(keyword, stringCompare))
                    {
                        var renamedName = string.Format(replacement, newName, initReplacePartStr);
                        initReplacePartCount++;
                        initReplacePartStr = initReplacePartCount.ToString();

                        // no duplicate
                        while (table.FindColumnSchema(renamedName) != null)
                        {
                            renamedName = string.Format(replacement, newName, initReplacePartStr);
                            initReplacePartCount++;
                            initReplacePartStr = initReplacePartCount.ToString();
                        }

                        newName = renamedName;
                        // name is chaned and check is no longer required
                        break;
                    }
                }
            }

            // field name is ok to be used
            return(newName);
        }