实体框架 CTP5(代码优先)建模 - 查找表
假设具有以下表结构:
表:
**Tasks**
taskID int PK
taskName varchar
**Resources**
resourceID int PK
resourceName varchar
**Assignments**
assignmentID int PK
taskID int FK
resourceID int FK
分配表将任务与分配给该任务的资源相关联。是否可以使用模型构建器映射此结构,以便我不必创建分配 poco 类 - 隐藏一些底层数据结构?
IE:
public class Task
{
public int taskID { get; set; }
public string taskName { get; set; }
public virtual ICollection<Resource> resourceItems { get; set; }
}
public class Resource
{
public int resourceID { get; set; }
public string resourceName { get; set; }
}
如何使用模型构建器将任务映射到资源而不创建分配 poco 类?
Assume the following table structure:
Tables:
**Tasks**
taskID int PK
taskName varchar
**Resources**
resourceID int PK
resourceName varchar
**Assignments**
assignmentID int PK
taskID int FK
resourceID int FK
The assignments table relates a task with the resource that is assigned to it. Is it possible to map this structure with the model builder so that I do not have to create an Assignment poco class - hiding some of the underlying data structure?
I.E.:
public class Task
{
public int taskID { get; set; }
public string taskName { get; set; }
public virtual ICollection<Resource> resourceItems { get; set; }
}
public class Resource
{
public int resourceID { get; set; }
public string resourceName { get; set; }
}
How can I use the model builder to map tasks to resources without creating an assignment poco class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑,我面前没有 IDE,所以这可能不是确切的“最新”语法,但它应该可以帮助您入门:
Here is an article about this very thing.
Edit, I dont have an IDE in front of me so this might not be the exact "latest" syntax, but it should get you started: