Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relational: Entity splitting support #620

Closed
Tracked by #22953 ...
divega opened this issue Sep 4, 2014 · 26 comments · Fixed by #29062
Closed
Tracked by #22953 ...

Relational: Entity splitting support #620

divega opened this issue Sep 4, 2014 · 26 comments · Fixed by #29062
Assignees
Labels
area-migrations area-model-building area-query area-save-changes closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. ef6-parity type-enhancement
Milestone

Comments

@divega
Copy link
Contributor

divega commented Sep 4, 2014

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)

@ilmax
Copy link
Contributor

ilmax commented Sep 4, 2014

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

@AndriySvyryd
Copy link
Member

Related to TPT #2266

@ajcvickers
Copy link
Member

Note: consider optional relationships: #9773

@AndriySvyryd
Copy link
Member

AndriySvyryd commented Sep 19, 2017

  • 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);
});

@netspark
Copy link

netspark commented Oct 4, 2017

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

@jansomers
Copy link

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

@maurei
Copy link

maurei commented Nov 27, 2018

Any update? Would love to see this feature incorporated.

@ajcvickers
Copy link
Member

@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.

@GeorgeTsaplin
Copy link

GeorgeTsaplin commented Jun 14, 2019

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

AndriySvyryd added a commit that referenced this issue Jun 24, 2022
Add check constraint and trigger annotation support to migration snapshot
Improve owned type FK discovery

Part of #620
AndriySvyryd added a commit that referenced this issue Jun 24, 2022
Add check constraint and trigger annotation support to migration snapshot
Improve owned type FK discovery

Part of #620
AndriySvyryd added a commit that referenced this issue Jun 28, 2022
Don't use identity be default for columns with FKs even when the property is mapped to other columns that should use identity

Part of #620
AndriySvyryd added a commit that referenced this issue Jun 29, 2022
Don't use identity by default for columns with FKs even when the property is mapped to other columns that should use identity
Update value generation on properties when an entity type is no longer mapped to a table or is mapped again

Part of #620
@ajcvickers ajcvickers modified the milestone: 7.0.0 Sep 6, 2022
smitpatel added a commit that referenced this issue Sep 12, 2022
smitpatel added a commit that referenced this issue Sep 12, 2022
smitpatel added a commit that referenced this issue Sep 15, 2022
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 15, 2022
smitpatel added a commit that referenced this issue Sep 15, 2022
smitpatel added a commit that referenced this issue Sep 15, 2022
smitpatel added a commit that referenced this issue Sep 15, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-rc2 Sep 16, 2022
@OskarKlintrot
Copy link

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?

@ajcvickers
Copy link
Member

@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.

@ajcvickers ajcvickers modified the milestones: 7.0.0-rc2, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations area-model-building area-query area-save-changes closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. ef6-parity type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.