How should I seed data to many to many relation in Entity Framework Code first 5.0
Just create a few movies and a few types and create relationships by adding some of those types to the Movie.Types
collection (or the other way around), for example:
protected override void Seed(MyContext context)
{
var movie1 = new Movie { Name = "A", Types = new List<Type>() };
var movie2 = new Movie { Name = "B", Types = new List<Type>() };
var movie3 = new Movie { Name = "C", Types = new List<Type>() };
var type1 = new Type { MovieType = "X" };
var type2 = new Type { MovieType = "Y" };
movie1.Types.Add(type1);
movie2.Types.Add(type1);
movie2.Types.Add(type2);
movie3.Types.Add(type2);
context.Movies.Add(movie1);
context.Movies.Add(movie2);
context.Movies.Add(movie3);
}