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);
}
时间: 2024-11-02 08:13:39