我得到了許多對許多relashionship表,但其中一人是不正常的,這我得到這個錯誤:The specified association foreign key columns 'FLS_FIL_ID' are invalid. The number of columns specified must match the number of primary key columns.
非規範化表6.1
的relashionship,我試圖要做的是在File和FlowStep之間,你可以看到它們是ICollections,但我沒有成功。
[Table("Controller.TB_FlowStep")]
public partial class FlowStep : Entity<int>
{
[StringLength(8)]
public string FLS_FLO_ID { get; set; }
[Key]
[Column(Order = 0)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int FLS_FIL_ID { get; set; }
[Key]
[Column(Order = 1)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int FLS_STE_ID { get; set; }
public DateTime FLS_TimeStamp { get; set; }
[Key]
[Column(Order = 2)]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public int FLS_STS_ID { get; set; }
public virtual Flow Flow { get; set; }
public virtual Step Step { get; set; }
public virtual StepStatus StepStatus { get; set; }
public virtual ICollection<File> File { get; set; }
}
[Table("Controller.TB_File")]
public partial class File
{
[Key]
public int FIL_Id { get; set; }
public DateTime FIL_Date { get; set; }
[Required]
[StringLength(1)]
public string FIL_Type { get; set; }
[Column(TypeName = "ntext")]
[Required]
public string FIL_Body { get; set; }
[StringLength(20)]
public string FIL_SQC { get; set; }
[StringLength(10)]
public string FIL_ENV { get; set; }
public ICollection<FlowStep> FlowStep { get; set; }
}
而且我確實到目前爲止映射:
modelBuilder.Entity<FlowStep>()
.HasMany(e => e.File)
.WithMany(e => e.FlowStep)
.Map(e =>
{
e.MapLeftKey("FLS_FIL_ID");
e.MapRightKey("FIL_ID");
e.ToTable("TB_FlowStep");
});
爲什麼你需要三個'Key's在頭等艙?他們也是外國人嗎? – renakre 2015-04-06 13:16:34