Use both AddDbContextFactory() and AddDbContext() extension methods in the same project

It is, it’s all about understanding the lifetimes of the various elements in play and getting those set correctly. By default the DbContextFactory created by the AddDbContextFactory() extension method has a Singleton lifespan. If you use the AddDbContext() extension method with it’s default settings it will create a DbContextOptions with a Scoped lifespan (see the … Read more

Entity Framework Core Many to Many change navigation property names

Interesting bug, consider posting it to EF Core GitHub issue tracker. By idea what you have tried should do it modelBuilder.Entity<SystemUser>() .HasMany(x => x.LogBooks) .WithMany(x => x.SystemUsers) .UsingEntity<Dictionary<string, object>>(“LogBookSystemUsers”, x => x.HasOne<LogBook>().WithMany().HasForeignKey(“LogBookId”), x => x.HasOne<SystemUser>().WithMany().HasForeignKey(“SystemUserId”), x => x.ToTable(“LogBookSystemUsers”, “LogBooks”)); And it works for any other FK property names except the {RelatedEntity}Id when related entity PK … Read more