public async void CreateTableObject(TableModel table)
        {
            if (!table.IsNewTable && (table.Columns == null || table.Columns.Count() == 0))
            {
                await Task.Factory.StartNew(() =>
                {
                    ReverseEngineer reverseEngineer = new ReverseEngineer(this.Dispatcher);

                    EventParser.ParseMessage(this, this.Dispatcher, string.Empty, "Reading table information.");

                    table.Columns = table.Columns.AddRange(reverseEngineer.GetTableColumns(table.TableName).ToArray());

                    table.PrimaryKeyClusterConstraintName = reverseEngineer.GetTablePrimaryKeyCluster(table.TableName);
                });
            }

            table.IsNewTable = false;

            table.IsDeleted = false;

            Integrity.MapTable(table);

            TableObject tableControl = new TableObject(table);

            tableControl.TableMove += this.TableObject_Move;

            tableControl.RemoveTable += this.TableObject_Remove;

            tableControl.ForeignKeyColumnAdded += this.TableObject_ForeignKeyAdded;

            foreach (KeyValuePair <string, DatabaseRelation> relation in tableControl.ColumnRelationModel)
            {
                relation.Value.DatabaseRelationDelete += this.DatabaseRelation_Delete;

                this.columnRelationModel.Add(relation.Key, relation.Value);
            }

            this.Children.Add(tableControl);

            this.ResizeCanvas(tableControl.Location, tableControl.ActualHeight, tableControl.ActualWidth);

            if (this.IsLoaded)
            {
                tableControl.InvalidateVisual();

                this.AddRelationsDrawing(tableControl);
            }

            tableControl.TableColumnChanged += this.TableColumn_Changed;

            tableControl.TableHeaderChanged += this.TableHeader_Changed;
        }
        private void RedrawTableRelations(TableObject table)
        {
            List <KeyValuePair <string, DatabaseRelation> > changedRelations = new List <KeyValuePair <string, DatabaseRelation> >();

            foreach (string mapedRelation in table.LinkedRelations)
            {
                if (!this.columnRelationModel.ContainsKey(mapedRelation))
                {
                    continue;
                }

                DatabaseRelation relationKeyValue = this.columnRelationModel[mapedRelation];

                foreach (Path relationPath in this.FindVisualControls(typeof(Path)).Where(p => ((Path)p).Name.EndsWith(relationKeyValue.RelationshipName)))
                {
                    this.Children.Remove(relationPath);
                }

                changedRelations.Add(new KeyValuePair <string, DatabaseRelation>(mapedRelation, relationKeyValue));
            }

            UIElement[] tableControls = this.FindVisualControls(typeof(TableObject));

            foreach (KeyValuePair <string, DatabaseRelation> relation in changedRelations)
            {
                string[] tablesUsed = relation.Key.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);

                UIElement parentTable = tableControls.FirstOrDefault(to => ((TableObject)to).Table.TableName == tablesUsed[0]);

                if (parentTable == null)
                {
                    this.DrawStubRelation(table, relation);

                    continue;
                }

                this.DrawRelation((TableObject)parentTable, tableControls, relation);
            }

            table.InvalidateVisual();
        }