Skip to content

Conversation

@tpellissier-msft
Copy link
Collaborator

Summary

  • Add relationship metadata API to DataverseClient for creating and managing table relationships
  • Support for one-to-many (1:N) and many-to-many (N:N) relationships via Web API
  • New metadata model types for relationship configuration
  • Convenience extension helper for common lookup field scenarios

Changes

New API Methods on DataverseClient

  • create_one_to_many_relationship(lookup, relationship) - Create 1:N relationships with lookup fields
  • create_many_to_many_relationship(relationship) - Create N:N relationships with intersect tables
  • get_relationship(schema_name) - Query relationship metadata by schema name
  • delete_relationship(relationship_id) - Delete relationships by metadata ID

New Metadata Types (models/metadata.py)

  • LookupAttributeMetadata - Lookup field configuration
  • OneToManyRelationshipMetadata - 1:N relationship definition
  • ManyToManyRelationshipMetadata - N:N relationship definition
  • CascadeConfiguration - Cascade behavior settings
  • AssociatedMenuConfiguration - Navigation menu options
  • Label / LocalizedLabel - Multi-language label support

Extension Helper (extensions/relationships.py)

  • create_lookup_field() - Simplified helper for common lookup scenarios

Architecture

  • Relationship implementation extracted to _relationships.py mixin to keep _odata.py focused
  • All metadata types support additional_properties for extensibility

Test plan

  • 60 unit tests passing (25 new tests for metadata types)
  • Relationships example runs successfully against live Dataverse environment
  • Example is idempotent (cleans up previous runs automatically)

@tpellissier-msft tpellissier-msft requested a review from a team as a code owner January 20, 2026 19:41
Copilot AI review requested due to automatic review settings January 20, 2026 19:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive relationship metadata API support to the Dataverse SDK, enabling programmatic creation and management of table relationships through the Web API. The implementation follows a clean architecture with metadata models, a relationship operations mixin, and convenience helpers.

Changes:

  • New metadata model types (LocalizedLabel, Label, CascadeConfiguration, AssociatedMenuConfiguration, LookupAttributeMetadata, OneToManyRelationshipMetadata, ManyToManyRelationshipMetadata) with serialization support
  • Relationship CRUD operations via mixin pattern (_RelationshipOperationsMixin) integrated into _ODataClient
  • Public API methods on DataverseClient for creating/deleting/querying relationships
  • Convenience extension helper (create_lookup_field) for simplified lookup scenarios
  • Comprehensive unit tests (60 total, 25 new for metadata types)
  • Full working example demonstrating all relationship operations

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/PowerPlatform/Dataverse/models/metadata.py New metadata model types with to_dict() serialization for Web API
src/PowerPlatform/Dataverse/models/init.py Exports new metadata types
tests/unit/models/test_metadata.py Comprehensive unit tests for all metadata classes
tests/unit/models/init.py Test package initialization
src/PowerPlatform/Dataverse/data/_relationships.py Relationship operations mixin with create/read/delete methods
src/PowerPlatform/Dataverse/data/_odata.py Integration of relationship mixin into _ODataClient
src/PowerPlatform/Dataverse/client.py Public API methods for relationship operations
src/PowerPlatform/Dataverse/extensions/relationships.py Convenience helper for common lookup field scenarios
src/PowerPlatform/Dataverse/extensions/init.py Exports create_lookup_field helper
examples/advanced/relationships.py Complete working example demonstrating all features

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zhaodongwang-msft
Copy link
Collaborator

we should probably update README too

@tpellissier-msft
Copy link
Collaborator Author

we should probably update README too

Good call, updated README.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



@dataclass
class AssociatedMenuConfiguration:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you plan to keep these upto date with DV? Do they need regular maintenance to support any new ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan here is to implement just the core subset of properties that we need for our SDK functionality rather than maintain total parity with the .NET definitions, and I don't think we expect that core functionality to change. We would need to stay aware in case there were any server side changes to these models though so we should be careful not to add more than we need (eg. AssociatedMenuConfiguration is not strictly necessary for adding relationships so I've removed it in the latest iteration).

@tpellissier-msft tpellissier-msft force-pushed the feature/relationship-metadata-api branch 2 times, most recently from 884755f to b07d2e9 Compare January 30, 2026 20:00
- Add metadata dataclasses (LocalizedLabel, Label, CascadeConfiguration,
  AssociatedMenuConfiguration, LookupAttributeMetadata,
  OneToManyRelationshipMetadata, ManyToManyRelationshipMetadata)
- Add _RelationshipOperationsMixin with create/get/delete operations
- Add create_lookup_field() convenience method to DataverseClient
- Add comprehensive unit tests for all new functionality
- Add relationships.py example demonstrating the API

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tpellissier-msft tpellissier-msft force-pushed the feature/relationship-metadata-api branch from b07d2e9 to c248495 Compare January 30, 2026 20:04
- Move OData type constants to common/constants.py
- Add input/output examples to metadata to_dict() docstrings
- Remove .NET SDK references from _relationships.py docstrings
- Add __all__ to models/__init__.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tpellissier-msft tpellissier-msft force-pushed the feature/relationship-metadata-api branch from c248495 to c9c97ad Compare January 30, 2026 20:11
tpellissier and others added 2 commits January 30, 2026 12:17
- Revert emoji formatting changes in examples (file_upload, walkthrough,
  functional_testing, installation_example)
- Revert pyproject.toml changes (keep claude skill installer)
- Update README with only relationship-related changes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Aligns with _RelationshipOperationsMixin naming convention.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tpellissier and others added 3 commits January 30, 2026 12:44
Move cascade behavior string values ("Cascade", "NoCascade", "RemoveLink",
"Restrict") to constants.py per PR review feedback. Update CascadeConfiguration
to use these constants for its default values.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove the AssociatedMenuConfiguration class and related parameters from
relationship metadata types. This is a niche UI customization that most
users don't need, and can still be achieved via additional_properties.

Changes:
- Remove AssociatedMenuConfiguration class from metadata.py
- Remove associated_menu_configuration from OneToManyRelationshipMetadata
- Remove entity1/2_associated_menu_configuration from ManyToManyRelationshipMetadata
- Update example and tests accordingly

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rename solution_unique_name parameter to solution (shorter, consistent)
- Add keyword-only separator (*) for optional parameters
- Update tests to use new parameter style

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants