0
我正在爲我的管絃樂規劃工具開發實體關係數據模型。最終結果應該是ASP.NET/MVC4應用程序。如何在多對多關係代碼優先級上設置屬性?
這是我的E/R-圖的一部分:
在圖像上面我嘗試來可視化,有一個Event
和Composition
之間的多對多的關係。在我的模型中,我還希望可以存儲任意Event
的Composition
的錄音(可以存在來自不同事件/協奏曲的相同合成的許多不同錄製版本)。
這是我到目前爲止已經完成(與我的代碼,第一個數據模型相關的代碼):
public class Composition
{
public Composition()
{
Instruments = new Collection<Instrument>();
Events = new Collection<Event>();
}
[Key]
public int Id { get; set; }
public bool Active { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public TimeSpan Durata { get; set; }
public virtual Composer Composer { get; set; }
public virtual Composer Genre { get; set; }
public virtual ICollection<Instrument> Instruments { get; set; }
public virtual ICollection<Event> Events { get; set; }
}
_
public class Event
{
public Event()
{
Compositions = new Collection<Composition>();
Members = new Collection<Member>();
}
[Key]
public int Id { get; set; }
public bool Active { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public virtual ICollection<Member> Members { get; set; }
public virtual ICollection<Composition> Compositions { get; set; }
public virtual Calendar Calendar { get; set; }
public virtual EventType EventType { get; set; }
public virtual Location Location { get; set; }
}
我的問題:如果在我的代碼做我添加關係屬性「錄製」?
編輯:我必須創建一個鏈接表還是有更好的選擇嗎?
Thx爲鏈接。在將此標記爲答案之前,我應該做一些測試。 –
感謝您的答覆,我很高興您解決它。 – Tasio