efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Relational: Entity splitting support

Open divega opened this issue 12 years ago • 26 comments

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: https://github.com/dotnet/efcore/issues/17270#issuecomment-588037768

divega avatar Sep 04 '14 16:09 divega

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

ilmax avatar Sep 04 '14 17:09 ilmax

Related to TPT https://github.com/aspnet/EntityFrameworkCore/issues/2266

AndriySvyryd avatar Aug 29 '17 21:08 AndriySvyryd

Note: consider optional relationships: #9773

ajcvickers avatar Sep 14 '17 01:09 ajcvickers

  • [x] Model building
    • [x] Column name overrides
    • [x] Runtime model
    • [x] Compiled model
    • [x] Relational model
  • [x] Migrations
    • [x] Snapshot
    • [x] Seeding
  • [x] 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);
});

AndriySvyryd avatar Sep 19 '17 01:09 AndriySvyryd

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

netspark avatar Oct 04 '17 15:10 netspark

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

jansomers avatar Jan 11 '18 10:01 jansomers

Any update? Would love to see this feature incorporated.

maurei avatar Nov 27 '18 13:11 maurei

@maurei This issue is in the Backlog milestone. This means that it is not going to happen for the 3.0 release. We will re-assess the backlog following the 3.0 release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

ajcvickers avatar Nov 27 '18 16:11 ajcvickers

I suppose what Owned Entity Types can be used as an alternative for Entity Splitting and it's already implemented at EFCore 2.0.

GeorgeTsaplin avatar Jun 14 '19 07:06 GeorgeTsaplin

Hi. Do you have any update?

artsiomtserashkovich avatar Aug 28 '19 13:08 artsiomtserashkovich

@ArtemTereshkovich This issue is in the Backlog milestone. This means that it is not going to happen for the 3.0 release. We will re-assess the backlog following the 3.0 release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

ajcvickers avatar Aug 28 '19 18:08 ajcvickers

This feature is a must for people migrating legacy systems to EF.

mister-conor avatar Oct 02 '19 11:10 mister-conor

Yes please - consider the scenario where a table is split for patitionin causes (for example, to separate LOB and row data).

leus avatar Feb 11 '20 13:02 leus

Lacking this feature in EF Core stops me (like other people) from migrating legacy projects from EF 6.4. @ajcvickers Do you have any concrete plan/schedule? What does "considered-for-net-release" label mean? .NET 5 (scheduled in November 2020) or .NET Core 3.x (may happend earlier)?

bairog avatar Feb 20 '20 07:02 bairog

@bairog We'll consider adding it to EF Core 5 if there's enough time left, otherwise it will likely go into EF Core 7

AndriySvyryd avatar Feb 20 '20 20:02 AndriySvyryd

Hello. Do you have any updates? Is it going to be included to EF Core 5 release?

bairog avatar Sep 17 '20 07:09 bairog

@bairog no, this feature did not make it into the upcoming 5 release. We'll consider this again for the 6.0 planning

roji avatar Sep 17 '20 11:09 roji

Hello. Are you planning to implement this in EF Core 6.0? It is vital for EF6 feature parity. No single word about it in this devblogs announcement

bairog avatar Jan 21 '21 08:01 bairog

@bairog This is a stretch goal for EF Core 6.0, as indicated by consider-for-current-release label. This means we may get to it for 6.0 if we have time in the schedule, but you shouldn't count on it.

ajcvickers avatar Jan 21 '21 16:01 ajcvickers

So it looks like even EFCore 6.0 LTS most likely will not have the entire list of current EF 6.4 features. Very disappointing to hear :(

bairog avatar Jan 21 '21 16:01 bairog