如果有人能告诉我为什么实体框架没有为以下模型创建连接表,我将不胜感激。它正在为类型和功能创建表,但不会创建将它们连接起来的表。
public class DeviceType
{
[Display(Name = "ID")]
public int DeviceTypeID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public IEnumerable<DeviceFeature> DeviceFeatures { get; set; }
}
public class DeviceFeature
{
[Display(Name = "ID")]
public int DeviceFeatureID { get; set; }
[Required]
public string Name { get; set; }
public string Description { get; set; }
public IEnumerable<DeviceType> DeviceTypes { get; set; }
}
public class DeviceFeatureView
{
public virtual IEnumerable<DeviceType> DeviceTypes { get; set; }
public virtual IEnumerable<DeviceFeature> DeviceFeatures { get; set;
}
答案 0 :(得分:1)
您不需要桥梁来创建多对多关系。 EF将弄明白。将导航属性的类型从>>> x = np.array([1, 2, 2.5])
>>> x
array([ 1. , 2. , 2.5])
>>>
>>> x.astype(float)
array([ 1. , 2. , 2.5])
更改为IEnumerable
,如下所示:
ICollection
有关它的更多信息here。