Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

ef core many to many fluent api

        modelBuilder.Entity<Customer>()
            .HasMany(p => p.Colors)
            .WithMany(p => p.Customers)
            .UsingEntity<Dictionary<string, object>>(
                "CustomerColor",
                j => j
                    .HasOne<Color>()
                    .WithMany()
                    .HasForeignKey("ColorId"),
                j => j
                    .HasOne<Customer>()
                    .WithMany()
                    .HasForeignKey("CustomerId"));
Source by github.com #
 
PREVIOUS NEXT
Tagged: #ef #core #fluent #api
ADD COMMENT
Topic
Name
1+1 =