如何在实体框架CTP5中映射多对多关系?
我正在尝试使用 3 个表(用户 - 联结表 - 语言)映射 2 种类型(用户 -> 语言),并且看起来 modelBuilder 期望两种类型相互引用(例如 user.languagesSpoken 和语言.用户说话)。所以基本上我可以构建类似的东西modelBuilder.Entity
。
然而,我不需要从语言到用户的参考 - 并且无法弄清楚如何映射它..
另外,有没有办法指定连接表名称?
谢谢!
I'm trying to map 2 types (user -> languages) using 3 tables (user - junction table - languages), and looks like the modelBuilder is expecting both types to have a reference to each other (like user.languagesSpoken, and language.UsersSpeaking). So basically I can build something likemodelBuilder.Entity<User>().HasMany(x=>x.LanguagesSpoken).WithMany(x=>x.UsersSpeaking)
.
I don't need a reference from language to user, however - and can't figure out how to map that..
Also, is there a way to specify a junction table name ?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面的方法可以解决这个问题:
The following will do the trick: