【发布时间】:2011-05-14 04:49:17
【问题描述】:
我刚刚开始使用 EF,并且观看了一些很棒的教程视频。我被以下问题困住了。
我有一个文件集合类,我希望这些文件与事件和/或人相关联
public class file{
public int id {get;set;}
public string path {get;set;}
}
public event {
public int id {get;set;}
public string eventname {get;set}
public virtual ICollection<file> files {get;set;}
public event(){ files = new list<file>();}
}
public person {
public int id {get;set;}
public string name {get;set}
public virtual ICollection<file> files {get;set;}
public person(){ files = new list<file>();}
}
现在当我生成数据库时,我的文件表有一个 PersonID 和 EventID。
我希望能够让用户将文件附加到人员和/或事件。
【问题讨论】:
-
现在数据库和对象模型都设置好了,任何关于我应该如何接近控制器和视图以添加新人员并允许用户上传文件并在文件之间建立必要关系的建议和人?
标签: c# entity-framework entity-framework-4 ef-code-first