public void Add( Table masterTable, Table slaveTable, bool isCascadeDelete, bool isCascadeUpdate) { if (masterTable is null) { throw new ArgumentNullException(nameof(masterTable)); } if (slaveTable is null) { throw new ArgumentNullException(nameof(slaveTable)); } if (!_linkValidator.IsUnique(masterTable: masterTable, slaveTable: slaveTable)) { throw new ArgumentException($"A link between tables {masterTable.Name} and {slaveTable.Name} is already exists."); } int foreignKeyId = _attributeService.AddForeignKey(masterTable: masterTable, slaveTable: slaveTable); ForeignKey foreignKey = _attributeService.GetById(id: foreignKeyId) as ForeignKey; PrimaryKey primaryKey = GetPrimaryKey(table: masterTable); Link link = new Link( masterAttribute: primaryKey, slaveAttribute: foreignKey, isDeleteCascade: isCascadeDelete, isUpdateCascade: isCascadeUpdate) { MasterAttributeId = masterTable.Id, SlaveAttributeId = slaveTable.Id }; _linkRepository.Add(entity: link); }