protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Seed(); //A side method to add the constraints
//Creation of many-to-many relationship:
modelBuilder.Entity<UserEntity>()
.HasMany(x => x.CoffeeShops) // Specifies that a User can have many Coffee shops.
.WithMany(x => x.Users) // Specifies that a Coffee shop can have many Users.
.UsingEntity(j => j.ToTable("UserCoffeeShops")); // Explicitly names the join table. (If I don’t specify this, EF Core will)
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Seed(); //A side method to add the constraints
//Creation of many-to-many relationship:
modelBuilder.Entity<UserEntity>()
.HasMany(x => x.CoffeeShops) // Specifies that a User can have many Coffee shops.
.WithMany(x => x.Users) // Specifies that a Coffee shop can have many Users.
.UsingEntity(j => j.ToTable("UserCoffeeShops")); // Explicitly names the join table. (If I don’t specify this, EF Core will)
}