-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Closed
Copy link
Description
After moving to version 7, we are now missing IndexerProperty in scaffolded DBContext for many to many relations.
DbContext, the problematic part of code:
entity.HasMany(d => d.MockupsNavigation).WithMany(p => p.Users)
.UsingEntity<Dictionary<string, object>>(
"UserMockup",
r => r.HasOne<Mockup>().WithMany()
.HasForeignKey("MockupId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("user_mockup_mockup_id_fkey"),
l => l.HasOne<User>().WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("user_mockup_user_id_fkey"),
j =>
{
j.HasKey("UserId", "MockupId").HasName("user_mockup_pkey");
j.ToTable("user_mockup");
//Missing code in EF7
//j.IndexerProperty<long>("UserId").ValueGeneratedOnAdd().HasColumnName("user_id");
//j.IndexerProperty<long>("MockupId").ValueGeneratedOnAdd().HasColumnName("mockup_id");
});
We are getting an error on SaveChangesAsync when we try to connect user
with mockup
instance.
Exception message
PostgresException: 42703: column "MockupId" of relation "user_mockup" does not exist
After adding these 2 missing lines everything works fine.
We couldn't find in the documentation that something has been changed compared to the previous version.
Is there any configuration parameter that we need to add now to have the previous behavior?
Include provider and version information
EF Core version: 7.0
Database provider: PostgreSQL
Target framework: NET 7.0
Operating system:
IDE: (e.g. Visual Studio 2022 17.4)
filipbekic01 and miroljub1995filipbekic01