1.http://www.cnblogs.com/libingql/archive/2013/01/31/2888201.html

2.多对多

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//多对多
Database.SetInitializer<CmsDbContext>(null);

modelBuilder.Entity<Article>()
.HasMany(e => e.Tags)
.WithMany(e => e.Articles)
.Map(m =>
{
m.ToTable("ArticleTag");
m.MapLeftKey("ArticleId");
m.MapRightKey("TagId");
});

base.OnModelCreating(modelBuilder);
}

05-08 15:49