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

Ignoring of configured m:m foreign key column names #91

Open
Zattor opened this issue Jan 17, 2024 · 4 comments
Open

Ignoring of configured m:m foreign key column names #91

Zattor opened this issue Jan 17, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@Zattor
Copy link

Zattor commented Jan 17, 2024

Hello @msawczyn,

is it possible to upload the version 4.2.3.5? As mentioned in this issue I have some problems upgrading the tool and as a workaround would like to use the last version without any problems.

I try to replicate and list them when I have time to do so, but currently these issues arrived after trying to upgrade to a higher version:

  • this issue
  • changing indexes, foreign keys and column names for existing m:m relation
  • SQLscript generation not working because of wrong index/fk names given by the tools generation

I try my best to give more detailed descriptions when replicating, but having the old version would be perfect and for teh time being a short fix.

Thank you btw for this great tool!

@Zattor
Copy link
Author

Zattor commented Jan 17, 2024

At least I can confirm that updating to 4.2.4.4 and adding a migration it's trying to update all my primary/foreign keys, indexes and columns in m:m mapping tables.

here is an example of a configuration for m:m relation in the generated db context:

modelBuilder.Entity<global:XYZ.User>()
            .HasMany<global::XYZ.Entity>(p => p.LeadingEntities)
            .WithMany(p => p.EntityLeaders)
.UsingEntity<Dictionary<string, object>>(right => right.HasOne<global::global::XYZ.Entity>().WithMany().HasForeignKey("LeadingEntitiesId").OnDelete(DeleteBehavior.Cascade),left => left.HasOne<global::XYZ.User>().WithMany().HasForeignKey("EntityLeadersId").OnDelete(DeleteBehavior.Cascade),join => join.ToTable("Entity_EntityLeaders_x_User_LeadingEntities"));

will be change to

.UsingEntity<Dictionary<string, object>>(right => right.HasOne<global::global::XYZ.Entity>().WithMany().HasForeignKey("Id").OnDelete(DeleteBehavior.Cascade),left => left.HasOne<global::XYZ.User>().WithMany().HasForeignKey("Id").OnDelete(DeleteBehavior.Cascade),join => join.ToTable("Entity_EntityLeaders_x_User_LeadingEntities"));

There are like 9 m:m relations like this present, so I won't copy all of them. After creating a migration you can see it will try to drop all indexes, fk and pk of the mapping table and drop some columns, which would be horrible... And then creating new FK etc.

I did specify the key column names, but it seams the are getting ignored?
image

I needed to do this a while back because the tool was fiddling with my column/FK names.

I will try another version, but just wanted to share this findings

@Zattor
Copy link
Author

Zattor commented Jan 17, 2024

Using v4.2.5.1 it changes them to

.UsingEntity<Dictionary<string, object>>(right => right.HasOne<global::global::XYZ.Entity>().WithMany().HasForeignKey("Opportunity_Id").OnDelete(DeleteBehavior.Cascade),left => left.HasOne<global::XYZ.User>().WithMany().HasForeignKey("User_Id").OnDelete(DeleteBehavior.Cascade),join => join.ToTable("Entity_EntityLeaders_x_User_LeadingEntities"));

I looked it up and it seems it was a bugfix for this version. But it's still ignoring the provided FK names.

@Zattor
Copy link
Author

Zattor commented Jan 17, 2024

Manually changing it back works and that's what I'll do for no, so no need for the version.

Updatíng the title because the false column names or ignoring of the configured ones seems to be the issue.

@Zattor Zattor changed the title Missing Tool version v4.2.3.5 Ignoring of configured m:m foreign key column names Jan 17, 2024
@msawczyn
Copy link
Owner

As a reference, all prior releases are available on the releases page here at GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Bug Reports
Development

No branches or pull requests

2 participants