public void Build_dependency_tree_from_model()
        {
            DbModelDependencyWalker dependencyWalker = new DbModelDependencyWalker(_model);
            var tables = dependencyWalker.SortTablesByForeignKeyReferences();

            DisplayTableDetails(tables);

            Assert.That(tables[0].Name, Is.EqualTo("Categories"));
            Assert.That(tables[1].Name, Is.EqualTo("Customers"));
            Assert.That(tables[2].Name, Is.EqualTo("Employees"));
            Assert.That(tables[3].Name, Is.EqualTo("Shippers"));
            Assert.That(tables[4].Name, Is.EqualTo("Suppliers"));
            Assert.That(tables[5].Name, Is.EqualTo("Orders"), "Order is dependent on Customers, Employees, Shippers");
            Assert.That(tables[6].Name, Is.EqualTo("Products"), "Products is dependent on Suppliers, Categories");
            Assert.That(tables[7].Name, Is.EqualTo("Order Details"), "Order Details is dependent on Orders, Products");
        }
        /// <summary>
        /// 	Execute the command.
        /// </summary>
        public override void Execute()
        {
            var editor = Services.Resolve<IEditor>("txt-editor");
            editor.FileName = null;
            HostWindow.DisplayDockedForm(editor as DockContent);

            if (HostWindow.DatabaseInspector.DbSchema == null)
            {
                HostWindow.DatabaseInspector.LoadDatabaseDetails();
            }

            var dependencyWalker = new DbModelDependencyWalker(HostWindow.DatabaseInspector.DbSchema);
            var tables = dependencyWalker.SortTablesByForeignKeyReferences();

            var sb = new StringBuilder();
            foreach (DbModelTable table in tables)
            {
                sb.AppendLine(table.FullName);
            }

            editor.AllText = sb.ToString();
        }