I use EF Code First and have a problem in n-n relationship, assume we have a singer that sing in some genres, so we need this models: Artist, Genre, and ArtistsGenres, I def
I would suggest you to go with the simpler approach of creating another model ArtistGenre and let EF figure out the relationship on its own. Create the table as below.
public class ArtistGenre
{
public int Id;
public int GenreId;
public int ArtistId;
public virtual Genre Genre;
public virtual Artist Artist;
}
After that you will have another table added to the database by the above name with two foriegn key properties and one primary key.
Now, you can run the queries on this table. Say
var artist = myContext.ArtistGenre.where( g = g.GenreId == 1).ToList();
Now, artist wil hold all the artist under Genre with Id =1. You can do the vice-versa for Genres too in the similar way.
Hope it helps !!