猿问

如何在实体框架中创建多对多映射?

在这种情况下,我有2个实体,例如Contract,Media。


public class Media : Entity

{

    public string Name {get; set;}

    public bool Enabled

    *//other properties can be ignored..*

}


public class Contract : Entity

{

    public string Code {get; set;}

    *//other properties can be ignored..*

}

合同有许多媒体,看来它们是多对多的。


但!!首先在EF代码,我需要在ContractMedia表(EF自动生成)中再添加3个字段。例如StartDate,EndDate和Price。无法将其添加到媒体实体中。


在这种情况下如何映射?


温温酱
浏览 295回答 3
3回答
随时随地看视频慕课网APP
我要回答