EF5许多关系实体

时间:2012-04-20 18:46:04

标签: .net .net-4.5 entity-framework-5

我们正在使用EF5的预发布版本并首先执行代码。我有一个订单模型和一个产品模型(很多<>很多关系)。我使用OrderID,ProductId和Quantity字段创建了 OrderItems 模型。它不会自动生成链接表。以下是代码:

Imports System.ComponentModel.DataAnnotations

Public Class OrderItems
    Public Property OrderID As Long
    Public Property ProductID As Long
    Public Property Quantity As Integer
End Class

我是否必须将它们注释为必需或使用Association标记明确链接它们?

1 个答案:

答案 0 :(得分:0)

我认为在这种情况下使用 Code First Relationships Fluent API http://msdn.microsoft.com/en-us/data/hh134698.aspx

是个好主意