How to define Many-to-Many relationship through Fluent API Entity Framework?
Below is my model: public class TMUrl { //many other properties //only property with type Keyword public List<Keyword> Keywords{get;set;} } public class Keyword { //many other properties //only property with type TMUrl public List<TMUrl> Urls{get;set;} } So clearly, both the entities have many-to-many relationship. I chose fluent api to tell the entity-framework about this relationship i.e. modelBuilder.Entity<TMUrl> .HasMany(s => s.Keywords) .WithMany(s => s.URLs).Map(s => { s.MapLeftKey("KeywordId"); s.MapRightKey("UrlId"); s.ToTable("KeywordUrlMapping"); }); but when I do url.Keywords.Add