是否可以在实体框架 6 中使用代码优先和注释创建单向多对多关联?例子:
class Currency
{
public int id { get; set; }
}
class Country
{
public int id { get; set; }
// How i can annotate this property to say EF that it is many-to-many
// and it should create mapping table?
// I don't need navigation property to Country in Currency class!
public virtual IList<Currency> currencies { get; set; }
}
在 Java + JPA 注释上,我可以通过这种方式实现我需要的东西:
@OneToMany
@JoinTable(name = "MAPPING_TABLE", joinColumns = {
@JoinColumn(name = "THIS_ID", referencedColumnName = "ID")
}, inverseJoinColumns = {
@JoinColumn(name = "OTHER_ID", referencedColumnName = "ID")
})
那么,EF 是否具有相同的功能?