Skip to content

Relational: Entity splitting support #620

Description

@divega

This work item represents the mapping capability to slice the data contained by an object into multiple tables.

Limitations:

  • Properties mapped to multiple columns can't use store-generated values
  • Foreign keys and indexes split across tables won't be created in the database

Related: #17270 (comment)

Activity

  1. ilmax commented on Sep 4, 2014

    @ilmax
    Contributor

    I would love if this feature does not fill in the standard Relational library but perhaps is exposed as a additional feature (pay for play scenario) which I can plug in only if needed

  2. modified the milestone: Backlog on Sep 5, 2014
  3. AndriySvyryd commented on Aug 29, 2017

    @AndriySvyryd
    Member

    Related to TPT #2266

  4. ajcvickers commented on Sep 14, 2017

    @ajcvickers
    Contributor

    Note: consider optional relationships: #9773

  5. AndriySvyryd commented on Sep 19, 2017

    @AndriySvyryd
    Member
    • Model building
      • Column name overrides
      • Runtime model
      • Compiled model
      • Relational model
    • Migrations
      • Snapshot
      • Seeding
    • Update
    • Query
    • Tests
      • Non-PK columns duplicated across tables
      • Concurrency tokens
      • Customizing linking FK (By default it's required dependent)
      • Views
      • With triggers and owned types
      • With table splitting

    API proposal:

    modelBuilder.Entity<Customer>().SplitToTable("CustomerDetails", tb =>
    {
        // PK mapped to all tables by default
    
        // Any other property mapped to a split table is not mapped to the default table
        tb.Property(c => c.AlternateKey);
    
    	// Empty column name effectively removes the property from the mapping fragment
        tb.Property(c => c.AlternateKey).HasColumnName("");
    });
    
    modelBuilder.Entity<Customer>().ToTable("Customer", tb =>
    {
        // Properties can be explicitly mapped to the default table too
        tb.Property(c => c.AlternateKey);
    });
    
    modelBuilder.Entity<Customer>().SplitToView("CustomerView", tb =>
    {
        tb.Property(c => c.AlternateKey);
    });
  6. netspark commented on Oct 4, 2017

    @netspark

    Would be very appreciated for implementing this, we have a lot of legacy one-to-one tables in DB which make no sense to treat separately in backend

  7. jansomers commented on Jan 11, 2018

    @jansomers

    Would very much love this feature, also the optional relationships is a must have when implementing entity splitting

  8. modified the milestones: Backlog, 3.0.0 on May 17, 2018
  9. 63 remaining items

  10. added 2 commits that reference this issue on Sep 12, 2022
    bb72359
    bf10425
  11. added 2 commits that reference this issue on Sep 15, 2022
    b6e5a30
    8f20257
  12. added a commit that references this issue on Sep 15, 2022
    d9518a5
  13. modified the milestones: 7.0.0, on Sep 16, 2022
  14. OskarKlintrot commented on Oct 12, 2022

    @OskarKlintrot

    Can I somehow specify that the foreign key is already specified in a table? Right now, EF tells me that I must have the FK in the "main" table but the limitation in the issue descriptions only says that FK won't be created in the database. In my case it's already created, is it still not possible to have the FK in another table?

  15. ajcvickers commented on Oct 12, 2022

    @ajcvickers
    Contributor

    @OskarKlintrot Please open a new issue and attach a small, runnable project or post a small, runnable code listing that shows what you are attempting and what doesn't work.

  16. modified the milestones: , 7.0.0 on Nov 5, 2022
  17. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions