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"));
精彩评论