///--------------------------------------------------------------------------------
        /// <summary>This method gets the current model context for the item.</summary>
        ///
        /// <param name="parentModelContext">The parent model context from which to get current model context.</param>
        /// <param name="isValidContext">Output flag, signifying whether context returned is a valid one.</param>
        ///--------------------------------------------------------------------------------
        public static IDomainEnterpriseObject GetModelContext(Solution solutionContext, IDomainEnterpriseObject parentModelContext, out bool isValidContext)
        {
            isValidContext = true;
            IDomainEnterpriseObject modelContext = parentModelContext;

            while (modelContext != null)
            {
                if (modelContext is SqlViewProperty)
                {
                    return(modelContext);
                }
                else if (solutionContext.IsSampleMode == true && solutionContext.NeedsSample == true && modelContext is SqlView)
                {
                    solutionContext.NeedsSample = false;
                    SqlView parent = modelContext as SqlView;
                    if (parent.SqlViewPropertyList.Count > 0)
                    {
                        return(parent.SqlViewPropertyList[DataHelper.GetRandomInt(0, parent.SqlViewPropertyList.Count - 1)]);
                    }
                }
                #region protected
                else if (solutionContext.IsSampleMode == true && modelContext is DatabaseSource)
                {
                    SqlDatabase parent = (modelContext as DatabaseSource).SpecDatabase;
                    if (parent != null && parent.SqlViewList.Count > 0)
                    {
                        return(parent.SqlViewList[0].SqlViewPropertyList[DataHelper.GetRandomInt(0, parent.SqlViewList[0].SqlViewPropertyList.Count - 1)]);
                    }
                }
                else if (solutionContext.IsSampleMode == true && modelContext is Project)
                {
                    SqlDatabase parent = (modelContext as Project).OutputDatabase;
                    if (parent != null && parent.SqlViewList.Count > 0)
                    {
                        return(parent.SqlViewList[0].SqlViewPropertyList[DataHelper.GetRandomInt(0, parent.SqlViewList[0].SqlViewPropertyList.Count - 1)]);
                    }
                }
                #endregion protected

                if (modelContext is Solution)
                {
                    break;
                }
                modelContext = modelContext.GetParentItem();
            }

            #region protected
            #endregion protected

            isValidContext = false;
            return(null);
        }
        ///--------------------------------------------------------------------------------
        /// <summary>This loads information from a SqlServer database, using SMO.</summary>
        ///
        /// <param name="sqlDatabase">The input sql database</param>
        ///--------------------------------------------------------------------------------
        public void LoadSqlServerDatabase(Database sqlDatabase)
        {
            try
            {
                // load the basic database information
                SqlDatabaseName = sqlDatabase.Name;
                DbID            = sqlDatabase.ID;
                Owner           = sqlDatabase.Owner;
                try
                {
                    PrimaryFilePath        = sqlDatabase.PrimaryFilePath;
                    DefaultFileGroup       = sqlDatabase.DefaultFileGroup;
                    DefaultFullTextCatalog = sqlDatabase.DefaultFullTextCatalog;
                }
                catch
                {
                    // TODO: have specific Azure db load or identify Azure case
                }
                DefaultSchema = sqlDatabase.DefaultSchema;
                CreateDate    = sqlDatabase.CreateDate;
                Status        = sqlDatabase.Status.ToString();
                UserName      = sqlDatabase.UserName;
                State         = sqlDatabase.State.ToString();

                // load information for each property
                foreach (Microsoft.SqlServer.Management.Smo.Property loopProperty in sqlDatabase.Properties)
                {
                    if (DebugHelper.DebugAction == DebugAction.Stop)
                    {
                        return;
                    }
                    if (loopProperty.Expensive == false && loopProperty.IsNull == false && !String.IsNullOrEmpty(loopProperty.Value.ToString()))
                    {
                        SqlProperty property = new SqlProperty();
                        property.SqlPropertyID = Guid.NewGuid();
                        property.SqlDatabase   = this;
                        property.LoadProperty(loopProperty);
                        SqlPropertyList.Add(property);
                    }
                }

                try
                {
                    // load information for each extended property
                    foreach (ExtendedProperty loopProperty in sqlDatabase.ExtendedProperties)
                    {
                        if (DebugHelper.DebugAction == DebugAction.Stop)
                        {
                            return;
                        }
                        SqlExtendedProperty property = new SqlExtendedProperty();
                        property.SqlExtendedPropertyID = Guid.NewGuid();
                        property.SqlDatabase           = this;
                        property.LoadExtendedProperty(loopProperty);
                        SqlExtendedPropertyList.Add(property);
                    }
                }
                catch
                {
                    // TODO: have specific Azure db load or identify Azure case
                }

                // load information for each table
                foreach (Table loopTable in sqlDatabase.Tables)
                {
                    if (loopTable.IsSystemObject == true)
                    {
                        continue;
                    }
                    if (DebugHelper.DebugAction == DebugAction.Stop)
                    {
                        return;
                    }
                    SqlTable table = new SqlTable();
                    table.SqlTableID  = Guid.NewGuid();
                    table.SqlDatabase = this;
                    table.LoadTable(loopTable);
                    SqlTableList.Add(table);
                }

                // load information for each view
                foreach (Microsoft.SqlServer.Management.Smo.View loopView in sqlDatabase.Views)
                {
                    if (loopView.IsSystemObject == true)
                    {
                        continue;
                    }
                    SqlView view = new SqlView();
                    view.SqlViewID   = Guid.NewGuid();
                    view.SqlDatabase = this;
                    view.LoadView(loopView);
                    SqlViewList.Add(view);
                }
            }
            catch (ApplicationAbortException)
            {
                throw;
            }
            catch (Exception)
            {
                throw;
            }
        }