开发者

Entity Framework 4.1 RC: Override name of Many to Many join table

In my code I have a many to 开发者_开发知识库many relationship defined using:

modelBuilder.Entity<Post>()
        .HasMany( p => p.Authors ).WithMany();

Post.Authors is an ICollection of User entities.

The ModelBuilder automatically creates a table called PostUsers.

How can I override the table naming convention so that the ModelBuilder names the table PostAuthors when the database is created from the model?

Thanks!


You can use:

modelBuilder.Entity<Post>
    .HasMany(p => p.Authors)
    .WithMany()
    .Map(m => m.ToTable("PostAuthors", "dbo"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜