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

RevEng: Split Relationship Fluent API Line in OnModelCreating() #3394

Closed
lajones opened this issue Oct 9, 2015 · 4 comments
Closed

RevEng: Split Relationship Fluent API Line in OnModelCreating() #3394

lajones opened this issue Oct 9, 2015 · 4 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@lajones
Copy link
Contributor

lajones commented Oct 9, 2015

Currently for RevEng in OnModelCreating() we generate the fluent API configuring a relationship all on one line e.g.:

            modelBuilder.Entity<OneToOneFKToUniqueKeyDependent>(entity =>
            {
                entity.HasOne(d => d.OneToOneFKToUniqueKeyDependentFK).WithOne(p => p.OneToOneFKToUniqueKeyDependent).HasPrincipalKey<OneToOneFKToUniqueKeyPrincipal>(p => new { p.OneToOneFKToUniqueKeyPrincipalUniqueKey1, p.OneToOneFKToUniqueKeyPrincipalUniqueKey2 }).HasForeignKey<OneToOneFKToUniqueKeyDependent>(d => new { d.OneToOneFKToUniqueKeyDependentFK1, d.OneToOneFKToUniqueKeyDependentFK2 });
            }

This can get pretty long. Consider doing the following instead:

            modelBuilder.Entity<OneToOneFKToUniqueKeyDependent>(entity =>
            {
                entity.HasOne(d => d.OneToOneFKToUniqueKeyDependentFK)
                    .WithOne(p => p.OneToOneFKToUniqueKeyDependent)
                    .HasPrincipalKey<OneToOneFKToUniqueKeyPrincipal>(p => new { p.OneToOneFKToUniqueKeyPrincipalUniqueKey1, p.OneToOneFKToUniqueKeyPrincipalUniqueKey2 })
                    .HasForeignKey<OneToOneFKToUniqueKeyDependent>(d => new { d.OneToOneFKToUniqueKeyDependentFK1, d.OneToOneFKToUniqueKeyDependentFK2 });
            }
@divega divega changed the title RevEng: Consider Splitting Relationship Fluent API Line in OnModelCreating() RevEng: Split Relationship Fluent API Line in OnModelCreating() Oct 9, 2015
@divega
Copy link
Contributor

divega commented Oct 9, 2015

Minor edit on the title to make it a bit stronger 😄

@rowanmiller rowanmiller added this to the 7.0.0-rc1 milestone Oct 13, 2015
@rowanmiller rowanmiller modified the milestones: 7.0.0, 7.0.0-rc1 Oct 14, 2015
@lajones
Copy link
Contributor Author

lajones commented Oct 27, 2015

Note: HasIndex() method chain should also be considered for this - see #3579.

@lajones
Copy link
Contributor Author

lajones commented Oct 30, 2015

Split the relationship config lines with PR #3588.

@lajones
Copy link
Contributor Author

lajones commented Dec 1, 2015

Last part checked in with commit d0f53e6.

@lajones lajones closed this as completed Dec 1, 2015
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants