Skip to content

Adding a join entity instance doesn't populate collections on the participating entities #23659

@andleer

Description

@andleer

I don't know if this is a bug or am I missing something?

Two simple entities that are connected with a simple mapping table that contains a single payload item. Both (non-mapping) entities contain a collection of the opposing entity and a collection of the common mapping entity. If I add one of the non-mapping entities to the other's collection and attach the "base" entity to the context, the context mapping dbset is correctly populated but I am unable to default the mapping entity's payload in code or via fluent config.

I have tried populating the mapping entity along with the payload value and adding that to the context dbset and saving changes on the entity but the simple many to many collections on the non-mapping entities are not populated.

Seems like a catch 22.

  1. How do I set a payload value? Can it be set dynamically at runtime?
  2. If I need to build by graph via the mapping entity, why aren't the non-mapping collections updated?

Repo with tests:
https://github.com/andleer/BinaryOcean.EFCore5

EF Core version: 5.0.1
Database provider: Microsoft.EntityFrameworkCore.InMemory (5.0.1)
Target framework: .NET 5.0
Operating system: Win10
IDE: Microsoft Visual Studio Community 2019 Version 16.8.3

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions