Skip to content

[Bug] Cannot create N:N relations #365

Description

@aabols

Describe the bug

For an N:N relationship, the CLI allows to add the intersect table as a source. The generated service includes the usual methods. Attempting to create a new relation using the create() method fails. Reading with getAll() works.

Code Apps documentation doesn't mention any limitations or recommendations around N:N relationships (that I could find).

Steps to Reproduce

  1. pac code add-data-source -a dataverse -t <intersect-table-logical-name>
  2. Try to create a record using the generated service
  3. See error

Expected behavior

New record created in intersect table.

Actual behavior

Request fails with error message.

Screenshots or Error Messages

{
    "code": "0x80040800",
    "message": "The 'Create' method does not support entities of type '<intersect-table-logical-name>'. MessageProcessorCache returned MessageProcessor.Empty. ",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionSourceKey": "Api/PrePipeline",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepKey": "00000000-0000-0000-0000-000000000000",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiDepthKey": "0",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiActivityIdKey": "f6d0c6ea-45b8-4a23-b60b-4d21ad628ce6",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiPluginSolutionNameKey": "System",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiStepSolutionNameKey": "System",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionCategory": "ClientError",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionMessageName": "SdkEntityDoesNotSupportMessage",
    "@Microsoft.PowerApps.CDS.ErrorDetails.ApiExceptionHttpStatusCode": "400",
    "@Microsoft.PowerApps.CDS.HelpLink": "http://go.microsoft.com/fwlink/?LinkID=398563&error=Microsoft.Crm.CrmException%3a80040800&client=platform",
    "@Microsoft.PowerApps.CDS.InnerError.Message": "The 'Create' method does not support entities of type '<intersect-table-logical-name>'. MessageProcessorCache returned MessageProcessor.Empty. "
}

Environment information

  • pac v2.7.4+g06bb2eb

Activity

  1. eschavez commented on Jun 5, 2026

    @eschavez
    Collaborator

    Thanks for the report!

    This is a Dataverse platform constraint: intersect tables for N:N relationships do not support the standard Create message, which is why you're seeing error 0x80040800 / SdkEntityDoesNotSupportMessage. Dataverse requires using the OData `` association endpoint instead of a direct POST to the entity set.

    Workaround — until we add first-class N:N support in the generated service, you can call the association endpoint directly via fetch:

    // Associate record1 (fromId) → record2 (toId) via the relationship
    const dataverseUrl = "https://<your-env>.api.crm.dynamics.com";
    
    await fetch(
      `/api/data/v9.2/<from-table>s()/<relationship-name>/`,
      {
        method: "POST",
        headers: { "Content-Type": "application/json", "OData-Version": "4.0" },
        body: JSON.stringify({
          "@odata.id": `/api/data/v9.2/<to-table>s()`
        })
      }
    );

    To disassociate, use a DELETE to:
    /api/data/v9.2/<from-table>s()/<relationship-name>()/

    We're logging this to our backlog to improve pac code add-data-source so it either detects N:N intersect tables and generates relationship-aware associate() / disassociate() methods, or surfaces a clear error at CLI time. We'll update this issue as we make progress.

  2. aabols commented on Jun 5, 2026

    @aabols
    Author

    Sounds good, thank you!

    I wasn't sure if the "normal" Dataverse web API is fair game in code-apps, in terms of correctly inheriting the auth context, security roles etc., but I'm happy to hear that it is.

    In the interim I have gone with "manual" intersect tables with two N:1 relationships 🙈

  3. aabols commented on Jun 9, 2026

    @aabols
    Author

    I have tried using the Dataverse web api from the code app, but the fetch() fails, because it "violates the document's Content Security Policy."

    Am I missing something? Looks like the IFrame is preventing fetches to pass through. Am I supposed to use something from the SDK? I can't see any methods for invoking a "general" API endpoint.

  4. ergonza93 commented on Sep 29, 2026

    @ergonza93
    Collaborator

    Moving this to the ideas section. We still don't have a timeline for this.

  5. locked and limited conversation to collaborators on Sep 29, 2026
  6. converted this issue into a discussion #468 on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions